Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Dec 2019 18:44:17 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355885 - head/sys/dev/oce
Message-ID:  <201912181844.xBIIiHiw097524@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Wed Dec 18 18:44:16 2019
New Revision: 355885
URL: https://svnweb.freebsd.org/changeset/base/355885

Log:
  oce: Tighten input validation in the SIOCGI2C handler.
  
  Missing validation meant that it was possible to read 8 bytes beyond
  the end of sfp_vpd_dump_buffer.
  
  Reported by:	Ilja Van Sprundel <ivansprundel@ioactive.com>
  Reviewed by:	delphij, ram
  MFC after:	3 days
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D22859

Modified:
  head/sys/dev/oce/oce_if.c

Modified: head/sys/dev/oce/oce_if.c
==============================================================================
--- head/sys/dev/oce/oce_if.c	Wed Dec 18 18:43:44 2019	(r355884)
+++ head/sys/dev/oce/oce_if.c	Wed Dec 18 18:44:16 2019	(r355885)
@@ -593,27 +593,26 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t d
 		if (rc)
 			break;
 
-		if (i2c.dev_addr != PAGE_NUM_A0 &&
-		    i2c.dev_addr != PAGE_NUM_A2) {
+		if (i2c.dev_addr == PAGE_NUM_A0) {
+			offset = i2c.offset;
+		} else if (i2c.dev_addr == PAGE_NUM_A2) {
+			offset = TRANSCEIVER_A0_SIZE + i2c.offset;
+		} else {
 			rc = EINVAL;
 			break;
 		}
 
-		if (i2c.len > sizeof(i2c.data)) {
+		if (i2c.len > sizeof(i2c.data) ||
+		    i2c.len + offset > sizeof(sfp_vpd_dump_buffer)) {
 			rc = EINVAL;
 			break;
 		}
 
 		rc = oce_mbox_read_transrecv_data(sc, i2c.dev_addr);
-		if(rc) {
+		if (rc) {
 			rc = -rc;
 			break;
 		}
-
-		if (i2c.dev_addr == PAGE_NUM_A0)
-			offset = i2c.offset;
-		else
-			offset = TRANSCEIVER_A0_SIZE + i2c.offset;
 
 		memcpy(&i2c.data[0], &sfp_vpd_dump_buffer[offset], i2c.len);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912181844.xBIIiHiw097524>