aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2020-08-05 17:11:18 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2020-08-05 17:11:18 +0000
commitb1039a53836ab29bbc2239e5f8f95e1b972aa930 (patch)
tree17a78f2f2db4fe4d6f470db2c2c2f550d808f95e
parente5bc066b765354f41979012ae4d3d3a161dec54c (diff)
downloadsrc-b1039a53836ab29bbc2239e5f8f95e1b972aa930.tar.gz
src-b1039a53836ab29bbc2239e5f8f95e1b972aa930.zip
Fix memory corruption in USB network device drivers.
Approved by: so Security: FreeBSD-SA-20:21.usb_net Security: CVE-2020-7459
Notes
Notes: svn path=/releng/11.4/; revision=363921
-rw-r--r--sys/dev/usb/net/if_smsc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c
index baa4441583fc..ae2fc17a16ce 100644
--- a/sys/dev/usb/net/if_smsc.c
+++ b/sys/dev/usb/net/if_smsc.c
@@ -970,7 +970,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
struct mbuf *m;
struct usb_page_cache *pc;
uint32_t rxhdr;
- uint16_t pktlen;
+ int pktlen;
int off;
int actlen;
@@ -996,6 +996,9 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
/* The frame header is always aligned on a 4 byte boundary */
off = ((off + 0x3) & ~0x3);
+ if ((off + sizeof(rxhdr)) > actlen)
+ goto tr_setup;
+
usbd_copy_out(pc, off, &rxhdr, sizeof(rxhdr));
off += (sizeof(rxhdr) + ETHER_ALIGN);
rxhdr = le32toh(rxhdr);
@@ -1024,7 +1027,13 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
goto tr_setup;
}
-
+ if (pktlen > m->m_len) {
+ smsc_dbg_printf(sc, "buffer too small %d vs %d bytes",
+ pktlen, m->m_len);
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ m_freem(m);
+ goto tr_setup;
+ }
usbd_copy_out(pc, off, mtod(m, uint8_t *), pktlen);
/* Check if RX TCP/UDP checksumming is being offloaded */