Skip to content

Commit 7bfda1a

Browse files
gregkhSasha Levin
authored andcommitted
net: usb: kalmia: validate USB endpoints
commit c58b6c2 upstream. 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: d402612 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0aae18e commit 7bfda1a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/net/usb/kalmia.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,18 @@ kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
132132
{
133133
int status;
134134
u8 ethernet_addr[ETH_ALEN];
135+
static const u8 ep_addr[] = {
136+
1 | USB_DIR_IN,
137+
2 | USB_DIR_OUT,
138+
0};
135139

136140
/* Don't bind to AT command interface */
137141
if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
138142
return -EINVAL;
139143

144+
if (!usb_check_bulk_endpoints(intf, ep_addr))
145+
return -ENODEV;
146+
140147
dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK);
141148
dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK);
142149
dev->status = NULL;

0 commit comments

Comments
 (0)