Skip to contentSkip to conversation

sierra: avoid trailing bytes leading to garbage parsing

RFC New Oliver Neukum 1 participant 1 message Feb 17, 2022

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

RFC 1/1 sierra: avoid trailing bytes leading to garbage parsing

The driver's main loop isn't ready for a device sending some trailing bytes as it tests for an exact match between package and accumulated frames.
We would parse some garbage from the heap and follow its pointers.

---
 drivers/net/usb/smsc75xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/usb/smsc75xx.c +2 -1
index 95de452ff4da..649e43b4df4f 100644
@@ -2183,7 +2183,8 @@ static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 	if (skb->len < dev->net->hard_header_len)
 		return 0;
 
-	while (skb->len > 0) {
+	/* at least two u32 must be left to go on */
+	while (skb->len > 4 + 4) {
 		u32 rx_cmd_a, rx_cmd_b, align_count, size;
 		struct sk_buff *ax_skb;
 		unsigned char *packet;
Signature · 1 line
2.34.1