From: Szymon Heidrich Date: Mon, 13 Mar 2023 22:00:45 +0000 (+0100) Subject: net: usb: smsc75xx: Limit packet length to skb->len X-Git-Tag: baikal/mips/sdk5.8.2~140 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=c3b1dd85ab92a0c0f6ed9a3b8a50bdb8f0f31300;p=kernel.git net: usb: smsc75xx: Limit packet length to skb->len [ Upstream commit d8b228318935044dafe3a5bc07ee71a1f1424b8d ] Packet length retrieved from skb data may be larger than the actual socket buffer length (up to 9026 bytes). In such case the cloned skb passed up the network stack will leak kernel memory contents. Fixes: 1f4fa502fc00 ("smsc75xx: SMSC LAN75xx USB gigabit ethernet adapter driver") Signed-off-by: Szymon Heidrich Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index aa848be459ec7..229ff92e41cd9 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -2210,7 +2210,8 @@ static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) dev->net->stats.rx_frame_errors++; } else { /* MAX_SINGLE_PACKET_SIZE + 4(CRC) + 2(COE) + 4(Vlan) */ - if (unlikely(size > (MAX_SINGLE_PACKET_SIZE + ETH_HLEN + 12))) { + if (unlikely(size > (MAX_SINGLE_PACKET_SIZE + ETH_HLEN + 12) || + size > skb->len)) { netif_dbg(dev, rx_err, dev->net, "size err rx_cmd_a=0x%08x\n", rx_cmd_a);