Skip to contentSkip to conversation

net: usb: kalmia: validate USB endpoints

PATCH Applied Greg Kroah-Hartman 3 participants 4 messages Feb 23 – Feb 26

Subsystems (4)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 net: usb: kalmia: validate USB endpoints

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 <[email protected]>
Assisted-by gkh_clanker_2000
---
 drivers/net/usb/kalmia.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/usb/kalmia.c +7 -0
index 613fc6910f14..ee9c48f7f68f 100644
@@ -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;
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Greg Kroah-Hartman

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 <[email protected]>
Assisted-by gkh_clanker_2000

Hi Greg,

As a fix I think this warrants a fixes tag.
As this seems problem to go back to when this driver was added, perhaps this one:

Fixes d40261236e8e ("net/usb: Add Samsung Kalmia driver for Samsung GT-B3730")

Regardless, this looks good to me.

...

author maintainer
#2 lore raw
Quoted 16 lines · Simon Horman
Quoted 8 lines · Greg Kroah-Hartman

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 <[email protected]>
Assisted-by gkh_clanker_2000

Hi Greg,

As a fix I think this warrants a fixes tag.
As this seems problem to go back to when this driver was added, perhaps this one:

Quoted 7 lines
Fixes d40261236e8e ("net/usb: Add Samsung Kalmia driver for Samsung GT-B3730")

Regardless, this looks good to me.

...

Thanks for the review for this and the kaweth patch. And yes, I should have put a fixes tag there, but for stuff that's always been around, that's not really a big deal.

greg k-h

#3 lore raw
In reply to Greg Kroah-Hartman
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 23 Feb 2026 13:59:26 +0100 you wrote:

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 <[email protected]>
Assisted-by gkh_clanker_2000

[...]

Here is the summary with links:
- net: usb: kalmia: validate USB endpoints

    https://git.kernel.org/netdev/net/c/c58b6c29a4c9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html