aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-06-14 05:33:25 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-06-14 05:33:25 +0000
commit0be584a9496934fd6c9b029a1da757363be30d5c (patch)
treea60230e2a321c1cb4c09b55c3516270908b51d20
parent918c81b92db897ca8cd7c45fa17d06770517bb6c (diff)
downloadsrc-0be584a9496934fd6c9b029a1da757363be30d5c.tar.gz
src-0be584a9496934fd6c9b029a1da757363be30d5c.zip
MFC r362056:
Add missing range checks when receiving USB ethernet packets. Found by: Ilja Van Sprundel, IOActive Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/stable/10/; revision=362168
-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 7cac61395fa7..02f1bbf45e30 100644
--- a/sys/dev/usb/net/if_smsc.c
+++ b/sys/dev/usb/net/if_smsc.c
@@ -949,7 +949,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;
@@ -975,6 +975,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);
@@ -1003,7 +1006,13 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
ifp->if_iqdrops++;
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 */