Skip to content

Commit 00a39a1

Browse files
viviergregkh
authored andcommitted
usbnet: limit max_mtu based on device's hard_mtu
[ Upstream commit c7159e9 ] The usbnet driver initializes net->max_mtu to ETH_MAX_MTU before calling the device's bind() callback. When the bind() callback sets dev->hard_mtu based the device's actual capability (from CDC Ethernet's wMaxSegmentSize descriptor), max_mtu is never updated to reflect this hardware limitation). This allows userspace (DHCP or IPv6 RA) to configure MTU larger than the device can handle, leading to silent packet drops when the backend sends packet exceeding the device's buffer size. Fix this by limiting net->max_mtu to the device's hard_mtu after the bind callback returns. See https://gitlab.com/qemu-project/qemu/-/issues/3268 and https://bugs.passt.top/attachment.cgi?bugid=189 Fixes: f77f0ae ("net: use core MTU range checking in USB NIC drivers") Signed-off-by: Laurent Vivier <lvivier@redhat.com> Link: https://bugs.passt.top/show_bug.cgi?id=189 Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Link: https://patch.msgid.link/20260119075518.2774373-1-lvivier@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e3c1040 commit 00a39a1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/net/usb/usbnet.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,9 +1803,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
18031803
if ((dev->driver_info->flags & FLAG_NOARP) != 0)
18041804
net->flags |= IFF_NOARP;
18051805

1806-
/* maybe the remote can't receive an Ethernet MTU */
1807-
if (net->mtu > (dev->hard_mtu - net->hard_header_len))
1808-
net->mtu = dev->hard_mtu - net->hard_header_len;
1806+
if (net->max_mtu > (dev->hard_mtu - net->hard_header_len))
1807+
net->max_mtu = dev->hard_mtu - net->hard_header_len;
1808+
1809+
if (net->mtu > net->max_mtu)
1810+
net->mtu = net->max_mtu;
1811+
18091812
} else if (!info->in || !info->out)
18101813
status = usbnet_get_endpoints (dev, udev);
18111814
else {

0 commit comments

Comments
 (0)