Skip to content

Commit 4b063c0

Browse files
gregkhkuba-moo
authored andcommitted
net: usb: kaweth: validate USB endpoints
The kaweth driver should validate that the device it is probing has the proper number and types of USB endpoints it is expecting before it binds to it. If a malicious device were to not have the same urbs the driver will crash later on when it blindly accesses these endpoints. Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Simon Horman <horms@kernel.org> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Link: https://patch.msgid.link/2026022305-substance-virtual-c728@gregkh Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c58b6c2 commit 4b063c0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/net/usb/kaweth.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,13 @@ static int kaweth_probe(
883883
const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
884884
int result = 0;
885885
int rv = -EIO;
886+
static const u8 bulk_ep_addr[] = {
887+
1 | USB_DIR_IN,
888+
2 | USB_DIR_OUT,
889+
0};
890+
static const u8 int_ep_addr[] = {
891+
3 | USB_DIR_IN,
892+
0};
886893

887894
dev_dbg(dev,
888895
"Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n",
@@ -896,6 +903,12 @@ static int kaweth_probe(
896903
(int)udev->descriptor.bLength,
897904
(int)udev->descriptor.bDescriptorType);
898905

906+
if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
907+
!usb_check_int_endpoints(intf, int_ep_addr)) {
908+
dev_err(dev, "couldn't find required endpoints\n");
909+
return -ENODEV;
910+
}
911+
899912
netdev = alloc_etherdev(sizeof(*kaweth));
900913
if (!netdev)
901914
return -ENOMEM;

0 commit comments

Comments
 (0)