From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+63ee658b9a100ffadbe2@syzkaller.appspotmail.com>,
kuba@kernel.org, linux-usb@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] WARNING in usbnet_start_xmit/usb_submit_urb
Date: Thu, 9 Dec 2021 13:03:11 +0100 [thread overview]
Message-ID: <291da1b9-9f71-0f99-45f4-a25a259c8d6d@suse.com> (raw)
In-Reply-To: <000000000000a56e9105d0cec021@google.com>
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
On 15.11.21 08:28, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 048ff8629e11 Merge tag 'usb-5.16-rc1' of git://git.kernel...
> git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> console output: https://syzkaller.appspot.com/x/log.txt?x=1480ade1b00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=d6b387bc5d3e50f3
> dashboard link: https://syzkaller.appspot.com/bug?extid=63ee658b9a100ffadbe2
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1313cb7cb00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16a2f676b00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+63ee658b9a100ffadbe2@syzkaller.appspotmail.com
>
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
048ff8629e11
[-- Attachment #2: 0001-usbnet-sanity-check-for-endpoint-types.patch --]
[-- Type: text/x-patch, Size: 1967 bytes --]
From 853e421630f82fb3b7005ad0b294c091a064ac39 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 18 Nov 2021 18:15:03 +0100
Subject: [PATCH] usbnet: sanity check for endpoint types
A malicious device can pretend to be a device with a known
configuration of endpoints yet present endpoints of the wrong type
or too few or none at all.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/net/usb/usbnet.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 9a6450f796dc..b1f93810a6f3 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -91,6 +91,31 @@ static const char * const usbnet_event_names[] = {
[EVENT_NO_IP_ALIGN] = "EVENT_NO_IP_ALIGN",
};
+bool usbnet_validate_endpoints(struct usbnet *dev, struct usb_interface *intf, const struct driver_info *info)
+{
+ struct usb_host_interface *alt = intf->cur_altsetting;
+ struct usb_host_endpoint *e;
+ int num_endpoints = alt->desc.bNumEndpoints;
+
+ if (info->in > num_endpoints)
+ return false;
+ e = alt->endpoint + info->in;
+ if (!e)
+ return false;
+ if (!usb_endpoint_is_bulk_in(&e->desc))
+ return false;
+
+ if (info->out > num_endpoints)
+ return false;
+ e = alt->endpoint + info->out;
+ if (!e)
+ return false;
+ if (!usb_endpoint_is_bulk_out(&e->desc))
+ return false;
+
+ return true;
+}
+
/* handles CDC Ethernet and many other network "bulk data" interfaces */
int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
{
@@ -1772,6 +1797,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
} else if (!info->in || !info->out)
status = usbnet_get_endpoints (dev, udev);
else {
+ if (!usbnet_validate_endpoints(dev, udev, info))
+ goto out3;
dev->in = usb_rcvbulkpipe (xdev, info->in);
dev->out = usb_sndbulkpipe (xdev, info->out);
if (!(info->flags & FLAG_NO_SETINT))
--
2.26.2
next prev parent reply other threads:[~2021-12-09 12:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 7:28 [syzbot] WARNING in usbnet_start_xmit/usb_submit_urb syzbot
2021-11-15 14:31 ` Oliver Neukum
2021-12-04 10:18 ` Dmitry Vyukov
2021-11-18 17:20 ` Oliver Neukum
2021-11-18 17:34 ` syzbot
2021-11-25 13:37 ` Oliver Neukum
2021-11-25 13:48 ` syzbot
2021-11-25 17:39 ` [PATCH] usbnet: sanity check for endpoint types kernel test robot
2021-12-09 12:03 ` Oliver Neukum [this message]
2021-12-09 12:26 ` [syzbot] WARNING in usbnet_start_xmit/usb_submit_urb syzbot
2023-06-23 13:32 ` [syzbot] [usb?] " syzbot
2023-06-23 15:23 ` Alan Stern
2023-06-23 16:07 ` syzbot
2023-06-23 17:16 ` Alan Stern
2023-07-11 12:42 ` Oliver Neukum
2023-07-11 17:38 ` [PATCH] net: usbnet: Fix " Alan Stern
2023-07-11 20:12 ` Jakub Kicinski
2023-07-12 14:15 ` [PATCH v2] " Alan Stern
2023-07-14 4:00 ` patchwork-bot+netdevbpf
[not found] <89b4d11e-8e00-c78f-7b5a-5f77c1291088@suse.com>
2021-11-18 15:24 ` [syzbot] " syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=291da1b9-9f71-0f99-45f4-a25a259c8d6d@suse.com \
--to=oneukum@suse.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+63ee658b9a100ffadbe2@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).