2022-08-11 02:10:24

by Rondreis

[permalink] [raw]
Subject: kernerl v5.18 warn in bpa10x_open/usb_submit_urb

Hello,

When fuzzing the Linux kernel driver v5.18.0, the following crash was triggered.

HEAD commit: 4b0986a3613c92f4ec1bdc7f60ec66fea135991f (HEAD, tag: v5.18)
git tree: upstream

kernel config: https://pastebin.com/KecL2gaG
C reproducer: https://pastebin.com/r3wwCUAv
console output: https://pastebin.com/uL3vEh5E

Basically, in the c reproducer, we use the gadget module to emulate
the process of attaching a usb device (vendor id: 0x45e, product id:
0x6d, with function: loopback_null).
To reproduce this crash, we utilize a third-party library to emulate
the attaching process: https://github.com/linux-usb-gadgets/libusbgx.
Just clone this repository, make install it, and compile the c
reproducer with ``` gcc crash.c -lusbgx -o crash ``` will do the
trick.

It seems that an error state in struct hci_dev trigger such kernel warning.

The crash report is as follow:

```------------[ cut here ]------------
usb 7-1: BOGUS urb xfer, pipe 1 != type 3
WARNING: CPU: 0 PID: 10209 at drivers/usb/core/urb.c:502
usb_submit_urb+0x142c/0x1820 drivers/usb/core/urb.c:502
Modules linked in:
CPU: 0 PID: 10209 Comm: kworker/u9:0 Not tainted 5.18.0 #3
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Workqueue: hci0 hci_power_on
RIP: 0010:usb_submit_urb+0x142c/0x1820 drivers/usb/core/urb.c:502
Code: 7c 24 18 e8 36 92 95 fd 48 8b 7c 24 18 e8 fc cf 1b ff 41 89 d8
44 89 e1 4c 89 ea 48 89 c6 48 c7 c7 20 9f a7 86 e8 55 0d 10 02 <0f> 0b
e9 fe f2 ff ff e8 08 92 95 fd 66 90 e8 01 92 95 fd 41 be a6
RSP: 0018:ffffc9000319fa80 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff888107460000 RDI: fffff52000633f42
RBP: ffff8881076a4500 R08: ffffffff812beb18 R09: 0000000000000000
R10: 0000000000000005 R11: ffffed1023504f09 R12: 0000000000000001
R13: ffff888100865910 R14: 0000000000000002 R15: ffff888110724e00
FS: 0000000000000000(0000) GS:ffff88811a800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005555558340b8 CR3: 0000000111e11000 CR4: 0000000000350ef0
Call Trace:
<TASK>
bpa10x_submit_intr_urb drivers/bluetooth/bpa10x.c:149 [inline]
bpa10x_open+0x2c9/0x7c0 drivers/bluetooth/bpa10x.c:207
hci_dev_open_sync+0x1a3/0x2080 net/bluetooth/hci_sync.c:3898
hci_dev_do_open+0x32/0x70 net/bluetooth/hci_core.c:482
hci_power_on+0x133/0x630 net/bluetooth/hci_core.c:963
process_one_work+0x9cc/0x1650 kernel/workqueue.c:2289
worker_thread+0x623/0x1070 kernel/workqueue.c:2436
kthread+0x2ef/0x3a0 kernel/kthread.c:346
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
</TASK>


```