svn commit: r355885 - head/sys/dev/oce
Mark Johnston
markj at FreeBSD.org
Wed Dec 18 18:44:17 UTC 2019
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 at 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);
More information about the svn-src-all
mailing list