Re: [syzbot] [bluetooth?] KASAN: invalid-free in hci_req_sync_complete

syzbot
2024-06-23T03:08:02Z

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in hci_req_sync_complete

skb: ffff88802ca99900, skb fc: 0, rskb: ffff88802ca99540, rskb fc: 0, hci_req_sync_complete
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000f: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f]
CPU: 0 PID: 65 Comm: kworker/u33:0 Not tainted 6.10.0-rc3-syzkaller-00044-g2ccbdf43d5e7-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: hci2 hci_rx_work
RIP: 0010:hci_req_sync_complete+0x217/0x3d0 net/bluetooth/hci_request.c:110
Code: 48 c1 ea 03 80 3c 02 00 0f 85 76 01 00 00 4c 8b b3 08 0e 00 00 48 b8 00 00 00 00 00 fc ff df 49 8d 7e 7e 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 3a 01 00 00
RSP: 0018:ffffc90000d27b10 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff88801edac000 RCX: ffffffff816e69b9
RDX: 000000000000000f RSI: ffffffff816ef706 RDI: 000000000000007e
RBP: ffff88802ca99900 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000005 R12: 0000000000000000
R13: ffff88801edace08 R14: 0000000000000000 R15: 0000000000000c1a
FS: 0000000000000000(0000) GS:ffff88806b000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f599deb91b0 CR3: 000000002af2e000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
hci_event_packet+0x963/0x1170 net/bluetooth/hci_event.c:7479
hci_rx_work+0x2c4/0x1610 net/bluetooth/hci_core.c:4074
process_one_work+0x9fb/0x1b60 kernel/workqueue.c:3231
process_scheduled_works kernel/workqueue.c:3312 [inline]
worker_thread+0x6c8/0xf70 kernel/workqueue.c:3393
kthread+0x2c1/0x3a0 kernel/kthread.c:389
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:hci_req_sync_complete+0x217/0x3d0 net/bluetooth/hci_request.c:110
Code: 48 c1 ea 03 80 3c 02 00 0f 85 76 01 00 00 4c 8b b3 08 0e 00 00 48 b8 00 00 00 00 00 fc ff df 49 8d 7e 7e 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 3a 01 00 00
RSP: 0018:ffffc90000d27b10 EFLAGS: 00010207
RAX: dffffc0000000000 RBX: ffff88801edac000 RCX: ffffffff816e69b9
RDX: 000000000000000f RSI: ffffffff816ef706 RDI: 000000000000007e
RBP: ffff88802ca99900 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000005 R12: 0000000000000000
R13: ffff88801edace08 R14: 0000000000000000 R15: 0000000000000c1a
FS: 0000000000000000(0000) GS:ffff88806b000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f599deb91b0 CR3: 000000001a976000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 48 c1 ea 03 shr $0x3,%rdx
4: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1)
8: 0f 85 76 01 00 00 jne 0x184
e: 4c 8b b3 08 0e 00 00 mov 0xe08(%rbx),%r14
15: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
1c: fc ff df
1f: 49 8d 7e 7e lea 0x7e(%r14),%rdi
23: 48 89 fa mov %rdi,%rdx
26: 48 c1 ea 03 shr $0x3,%rdx
* 2a: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax <-- trapping instruction
2e: 48 89 fa mov %rdi,%rdx
31: 83 e2 07 and $0x7,%edx
34: 38 d0 cmp %dl,%al
36: 7f 08 jg 0x40
38: 84 c0 test %al,%al
3a: 0f 85 3a 01 00 00 jne 0x17a

Tested on:

commit: 2ccbdf43 Merge tag 'for-linus' of git://git.kernel.org..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=137c4c8e980000
kernel config: https://syzkaller.appspot.com/x/.config?x=b8786f381e62940f
dashboard link: https://syzkaller.appspot.com/bug?extid=35ebc808442df6420eae
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=11d3c1fa980000