Skip to content

Commit db6c3c0

Browse files
jhovolddavem330
authored andcommitted
net: lan78xx: fix division by zero in send path
Add the missing endpoint max-packet sanity check to probe() to avoid division by zero in lan78xx_tx_bh() in case a malicious device has broken descriptors (or when doing descriptor fuzz testing). Note that USB core will reject URBs submitted for endpoints with zero wMaxPacketSize but that drivers doing packet-size calculations still need to handle this (cf. commit 2548288 ("USB: Fix: Don't skip endpoint descriptors with maxpacket=0")). Fixes: 55d7de9 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Cc: [email protected] # 4.3 Cc: [email protected] <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6f68cd6 commit db6c3c0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,6 +4122,12 @@ static int lan78xx_probe(struct usb_interface *intf,
41224122

41234123
dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out, 1);
41244124

4125+
/* Reject broken descriptors. */
4126+
if (dev->maxpacket == 0) {
4127+
ret = -ENODEV;
4128+
goto out4;
4129+
}
4130+
41254131
/* driver requires remote-wakeup capability during autosuspend. */
41264132
intf->needs_remote_wakeup = 1;
41274133

0 commit comments

Comments
 (0)