Skip to contentSkip to conversation

net: usb: kaweth: validate USB endpoints

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

Subsystems (4)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 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 <[email protected]>
Assisted-by gkh_clanker_2000
---
 drivers/net/usb/kaweth.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/usb/kaweth.c +13 -0
index c9efb7df892e..a8c3ecf7d810 100644
@@ -885,6 +885,13 @@ static int kaweth_probe(
 	const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 	int result = 0;
 	int rv = -EIO;
+	static const u8 bulk_ep_addr[] = {
+		1 | USB_DIR_IN,
+		2 | USB_DIR_OUT,
+		0};
+	static const u8 int_ep_addr[] = {
+		3 | USB_DIR_IN,
+		0};
 
 	dev_dbg(dev,
 		"Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n",
@@ -898,6 +905,12 @@ static int kaweth_probe(
 		(int)udev->descriptor.bLength,
 		(int)udev->descriptor.bDescriptorType);
 
+	if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
+	    !usb_check_int_endpoints(intf, int_ep_addr)) {
+		dev_err(dev, "couldn't find required endpoints\n");
+		return -ENODEV;
+	}
+
 	netdev = alloc_etherdev(sizeof(*kaweth));
 	if (!netdev)
 		return -ENOMEM;
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Greg Kroah-Hartman

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

Hi Greg,

This seems to go back to the beginning of Git history, so this seems appropriate.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

That notwithstanding, this looks good to me.

#2 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 14:00:06 +0100 you wrote:

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

[...]

Here is the summary with links:
- [net] net: usb: kaweth: validate USB endpoints

    https://git.kernel.org/netdev/net/c/4b063c002ca7

You are awesome, thank you!

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