All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Heidrich <szymon.heidrich@gmail.com>
To: steve.glendinning@shawell.net, UNGLinuxDriver@microchip.com,
	davem@davemloft.net, edumazet@google.com
Cc: kuba@kernel.org, pabeni@redhat.com, szymon.heidrich@gmail.com,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] net: usb: smsc95xx: Limit packet length to skb->len
Date: Mon, 13 Mar 2023 23:01:24 +0100	[thread overview]
Message-ID: <20230313220124.52437-1-szymon.heidrich@gmail.com> (raw)

Packet length retrieved from skb data may be larger than
the actual socket buffer length (up to 1526 bytes). In such
case the cloned skb passed up the network stack will leak
kernel memory contents.

Fixes: 2f7ca802bdae ("net: Add SMSC LAN9500 USB2.0 10/100 ethernet adapter driver")
Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
---
 drivers/net/usb/smsc95xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 32d2c60d3..ba766bdb2 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1851,7 +1851,8 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 			}
 		} else {
 			/* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */
-			if (unlikely(size > (ETH_FRAME_LEN + 12))) {
+			if (unlikely(size > (ETH_FRAME_LEN + 12) ||
+				     size > skb->len)) {
 				netif_dbg(dev, rx_err, dev->net,
 					  "size err header=0x%08x\n", header);
 				return 0;
-- 
2.39.2


             reply	other threads:[~2023-03-13 22:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 22:01 Szymon Heidrich [this message]
2023-03-16  4:24 ` [PATCH] net: usb: smsc95xx: Limit packet length to skb->len Jakub Kicinski
2023-03-16 10:19   ` [PATCH v2] " Szymon Heidrich
2023-03-16 20:52     ` Jakub Kicinski
2023-03-18  5:10     ` patchwork-bot+netdevbpf
2023-03-16 11:13   ` [PATCH] " Szymon Heidrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230313220124.52437-1-szymon.heidrich@gmail.com \
    --to=szymon.heidrich@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steve.glendinning@shawell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.