From: Alan Stern <stern@rowland.harvard.edu>
To: syzbot <syzbot+9b57a46bf1801ce2a2ca@syzkaller.appspotmail.com>
Cc: Michal Kubecek <mkubecek@suse.cz>,
benjamin.tissoires@redhat.com, jikos@kernel.org,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] WARNING in hid_submit_ctrl/usb_submit_urb
Date: Wed, 18 Aug 2021 14:49:27 -0400 [thread overview]
Message-ID: <20210818184927.GD197200@rowland.harvard.edu> (raw)
In-Reply-To: <00000000000038c55d05c9d1dc3b@google.com>
On Wed, Aug 18, 2021 at 02:14:23AM -0700, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 794c7931a242 Merge branch 'linus' of git://git.kernel.org/..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13af2205300000
> kernel config: https://syzkaller.appspot.com/x/.config?x=96f0602203250753
> dashboard link: https://syzkaller.appspot.com/bug?extid=9b57a46bf1801ce2a2ca
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11ae58ce300000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11d71731300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+9b57a46bf1801ce2a2ca@syzkaller.appspotmail.com
>
> ------------[ cut here ]------------
> usb 1-1: BOGUS control dir, pipe 80000280 doesn't match bRequestType a1
> WARNING: CPU: 0 PID: 8434 at drivers/usb/core/urb.c:410 usb_submit_urb+0x149d/0x18a0 drivers/usb/core/urb.c:410
> Modules linked in:
> CPU: 0 PID: 8434 Comm: syz-executor752 Not tainted 5.14.0-rc6-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:usb_submit_urb+0x149d/0x18a0 drivers/usb/core/urb.c:410
> Code: 7c 24 40 e8 45 64 1f fc 48 8b 7c 24 40 e8 4b fc 0b ff 45 89 e8 44 89 f1 4c 89 e2 48 89 c6 48 c7 c7 e0 b2 27 8a e8 01 fc 91 03 <0f> 0b e9 a5 ee ff ff e8 17 64 1f fc 0f b6 1d 19 ca 01 08 31 ff 41
> RSP: 0018:ffffc90000effbd0 EFLAGS: 00010082
> RAX: 0000000000000000 RBX: ffff888027944058 RCX: 0000000000000000
> RDX: ffff8880235db880 RSI: ffffffff815d85c5 RDI: fffff520001dff6c
> RBP: ffff888021618140 R08: 0000000000000000 R09: 0000000000000000
> R10: ffffffff815d23fe R11: 0000000000000000 R12: ffff888018aff118
> R13: 00000000000000a1 R14: 0000000080000280 R15: ffff888021900400
> FS: 000000000223d300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00005614a6c2a160 CR3: 00000000222ca000 CR4: 0000000000350ef0
> Call Trace:
> hid_submit_ctrl+0x6ec/0xd80 drivers/hid/usbhid/hid-core.c:416
> usbhid_restart_ctrl_queue.isra.0+0x244/0x3a0 drivers/hid/usbhid/hid-core.c:258
The problem is that syzbot has created a device with a report length of
zero. If we use the padded length instead of the actual length, the
error should vanish.
I believe this is fixed by Michal's patch, below.
Alan Stern
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 794c7931a242
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -377,27 +377,26 @@ static int hid_submit_ctrl(struct hid_device *hid)
len = hid_report_len(report);
if (dir == USB_DIR_OUT) {
usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0);
- usbhid->urbctrl->transfer_buffer_length = len;
if (raw_report) {
memcpy(usbhid->ctrlbuf, raw_report, len);
kfree(raw_report);
usbhid->ctrl[usbhid->ctrltail].raw_report = NULL;
}
} else {
- int maxpacket, padlen;
+ int maxpacket;
usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0);
maxpacket = usb_maxpacket(hid_to_usb_dev(hid),
usbhid->urbctrl->pipe, 0);
if (maxpacket > 0) {
- padlen = DIV_ROUND_UP(len, maxpacket);
- padlen *= maxpacket;
- if (padlen > usbhid->bufsize)
- padlen = usbhid->bufsize;
+ len = DIV_ROUND_UP(len, maxpacket);
+ len *= maxpacket;
+ if (len > usbhid->bufsize)
+ len = usbhid->bufsize;
} else
- padlen = 0;
- usbhid->urbctrl->transfer_buffer_length = padlen;
+ len = 0;
}
+ usbhid->urbctrl->transfer_buffer_length = len;
usbhid->urbctrl->dev = hid_to_usb_dev(hid);
usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir;
next prev parent reply other threads:[~2021-08-18 18:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-18 15:46 [syzbot] WARNING in hid_submit_ctrl/usb_submit_urb syzbot
2021-08-18 9:14 ` syzbot
2021-08-18 18:49 ` Alan Stern [this message]
2021-08-18 20:13 ` syzbot
2021-08-19 15:26 ` Alan Stern
2021-08-19 17:35 ` syzbot
2021-08-19 19:53 ` Alan Stern
2021-08-20 0:40 ` syzbot
2021-08-20 14:06 ` Alan Stern
2021-08-24 11:53 ` Jiri Kosina
2021-08-24 12:34 ` Benjamin Tissoires
2021-08-31 9:51 ` Benjamin Tissoires
2021-08-31 13:34 ` Alan Stern
2021-08-31 19:53 ` Jiri Kosina
2021-09-01 15:38 ` Alan Stern
2021-09-01 15:51 ` Michal Kubecek
2021-08-24 11:50 ` Michal Kubecek
2021-08-30 19:22 ` Oleksandr Natalenko
2021-08-18 19:01 ` Alan Stern
2021-08-18 19:39 ` 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=20210818184927.GD197200@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=syzbot+9b57a46bf1801ce2a2ca@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).