Date: Sun, 14 Jun 2020 05:27:38 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r362167 - stable/11/sys/dev/usb/net Message-ID: <202006140527.05E5Rct3061248@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Sun Jun 14 05:27:37 2020 New Revision: 362167 URL: https://svnweb.freebsd.org/changeset/base/362167 Log: MFC r362056: Add missing range checks when receiving USB ethernet packets. Found by: Ilja Van Sprundel, IOActive Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/usb/net/if_smsc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/net/if_smsc.c ============================================================================== --- stable/11/sys/dev/usb/net/if_smsc.c Sun Jun 14 05:25:06 2020 (r362166) +++ stable/11/sys/dev/usb/net/if_smsc.c Sun Jun 14 05:27:37 2020 (r362167) @@ -970,7 +970,7 @@ smsc_bulk_read_callback(struct usb_xfer *xfer, usb_err 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_err /* 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_err 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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006140527.05E5Rct3061248>