Skip to content

Commit 11de1d3

Browse files
gregkhkuba-moo
authored andcommitted
net: usb: pegasus: validate USB endpoints
The pegasus 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: Petko Manolov <petkan@nucleusys.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://patch.msgid.link/2026022347-legibly-attest-cc5c@gregkh Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 12133a4 commit 11de1d3

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/net/usb/pegasus.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,19 @@ static void unlink_all_urbs(pegasus_t *pegasus)
812812

813813
static int alloc_urbs(pegasus_t *pegasus)
814814
{
815+
static const u8 bulk_ep_addr[] = {
816+
1 | USB_DIR_IN,
817+
2 | USB_DIR_OUT,
818+
0};
819+
static const u8 int_ep_addr[] = {
820+
3 | USB_DIR_IN,
821+
0};
815822
int res = -ENOMEM;
816823

824+
if (!usb_check_bulk_endpoints(pegasus->intf, bulk_ep_addr) ||
825+
!usb_check_int_endpoints(pegasus->intf, int_ep_addr))
826+
return -ENODEV;
827+
817828
pegasus->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
818829
if (!pegasus->rx_urb) {
819830
return res;
@@ -1168,6 +1179,7 @@ static int pegasus_probe(struct usb_interface *intf,
11681179

11691180
pegasus = netdev_priv(net);
11701181
pegasus->dev_index = dev_index;
1182+
pegasus->intf = intf;
11711183

11721184
res = alloc_urbs(pegasus);
11731185
if (res < 0) {
@@ -1179,7 +1191,6 @@ static int pegasus_probe(struct usb_interface *intf,
11791191

11801192
INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
11811193

1182-
pegasus->intf = intf;
11831194
pegasus->usb = dev;
11841195
pegasus->net = net;
11851196

0 commit comments

Comments
 (0)