]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: usb: kalmia: validate USB endpoints
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Feb 2026 12:59:26 +0000 (13:59 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 26 Feb 2026 02:56:43 +0000 (18:56 -0800)
The kalmia 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: d40261236e8e ("net/usb: Add Samsung Kalmia driver for Samsung GT-B3730")
Link: https://patch.msgid.link/2026022326-shack-headstone-ef6f@gregkh
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/kalmia.c

index 613fc6910f1481cc89cb5325a5cd12379aebf94a..ee9c48f7f68f95802de0881f11a16af01f43e694 100644 (file)
@@ -132,11 +132,18 @@ kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
 {
        int status;
        u8 ethernet_addr[ETH_ALEN];
+       static const u8 ep_addr[] = {
+               1 | USB_DIR_IN,
+               2 | USB_DIR_OUT,
+               0};
 
        /* Don't bind to AT command interface */
        if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
                return -EINVAL;
 
+       if (!usb_check_bulk_endpoints(intf, ep_addr))
+               return -ENODEV;
+
        dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK);
        dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK);
        dev->status = NULL;