Skip to contentSkip to conversation

sr9700: sanity check for packet length

PATCH Applied Oliver Neukum 3 participants 3 messages Feb 17, 2022 – Feb 18, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sr9700: sanity check for packet length

A malicious device can leak heap data to user space providing bogus frame lengths. Introduce a sanity check.

---
 drivers/net/usb/sr9700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/sr9700.c +1 -1
index b658510cc9a4..5a53e63d33a6 100644
@@ -413,7 +413,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 		/* ignore the CRC length */
 		len = (skb->data[1] | (skb->data[2] << 8)) - 4;
 
-		if (len > ETH_FRAME_LEN)
+		if (len > ETH_FRAME_LEN || len > skb->len)
 			return 0;
 
 		/* the last packet of current skb */
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Oliver Neukum

A malicious device can leak heap data to user space providing bogus frame lengths. Introduce a sanity check.

Quoted 9 lines
---
 drivers/net/usb/sr9700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/sr9700.c +0 -0
index b658510cc9a4..5a53e63d33a6 100644

drivers/net/usb/sr9700.c static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb) · line 416

Quoted 5 lines
drivers/net/usb/sr9700.c +1 -1
@@ -413,7 +413,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
                /* ignore the CRC length */
                len = (skb->data[1] | (skb->data[2] << 8)) - 4;
 
-               if (len > ETH_FRAME_LEN)
+               if (len > ETH_FRAME_LEN || len > skb->len)

good catch.

Quoted 6 lines
drivers/net/usb/sr9700.c +0 -1
                        return 0;
 
                /* the last packet of current skb */
--

2.34.1

#2 lore raw
In reply to Oliver Neukum
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 7 lines · On Thu, 17 Feb 2022 14:10:44 +0100 you wrote:

A malicious device can leak heap data to user space providing bogus frame lengths. Introduce a sanity check.

---
 drivers/net/usb/sr9700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- sr9700: sanity check for packet length

    https://git.kernel.org/netdev/net/c/e9da0b56fe27

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html