KASAN: use-after-free Read in __queue_work

Status: upstream: reported syz repro on 2020/08/03 15:06
First crash: 857d, last: 93d

Fix bisection: failed (bisect log)
similar bugs (7):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-49 KASAN: use-after-free Read in __queue_work C 19 1573d 1336d 0/3 public: reported C repro on 2019/04/13 00:00
linux-4.19 KASAN: use-after-free Read in __queue_work syz done 5 485d 857d 1/1 fixed on 2021/09/10 09:12
upstream KASAN: use-after-free Read in __queue_work syz 2 1904d 1868d 0/24 closed as invalid on 2017/10/27 09:34
upstream KASAN: use-after-free Read in __queue_work (3) syz done done 83 23d 852d 0/24 upstream: reported syz repro on 2020/08/08 21:27
upstream KASAN: use-after-free Read in __queue_work (2) C done done 577 1260d 1613d 16/24 fixed on 2020/01/08 01:07
upstream general protection fault in __queue_work (2) C done 7043 238d 1006d 0/24 auto-obsoleted due to no activity on 2022/11/16 06:42
linux-4.19 general protection fault in __queue_work (2) 1 330d 330d 0/1 auto-closed as invalid on 2022/05/12 22:08

Sample crash report:
Bluetooth: hci0 command 0x0c1a tx timeout
Bluetooth: hci0 command 0x0c1a tx timeout
Bluetooth: hci0 command 0x0c1a tx timeout
Bluetooth: hci0 command 0x0c1a tx timeout
BUG: KASAN: use-after-free in __queue_work+0xc2e/0xf70 kernel/workqueue.c:1385
Read of size 4 at addr ffff8880b3d28980 by task syz-executor.5/10730

CPU: 1 PID: 10730 Comm: syz-executor.5 Not tainted 4.14.230-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x281 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load4_noabort+0x68/0x70 mm/kasan/report.c:429
 __queue_work+0xc2e/0xf70 kernel/workqueue.c:1385
 queue_work_on+0x159/0x1d0 kernel/workqueue.c:1490
 queue_work include/linux/workqueue.h:491 [inline]
 req_run+0x2ca/0x4f0 net/bluetooth/hci_request.c:77
 hci_req_run_skb net/bluetooth/hci_request.c:89 [inline]
 __hci_req_sync+0x2b5/0x7e0 net/bluetooth/hci_request.c:214
 hci_req_sync+0x71/0xa0 net/bluetooth/hci_request.c:285
 hci_dev_cmd+0x451/0x710 net/bluetooth/hci_core.c:1890
 hci_sock_ioctl+0x344/0x690 net/bluetooth/hci_sock.c:1040
 sock_do_ioctl net/socket.c:974 [inline]
 sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
RIP: 0033:0x466459
RSP: 002b:00007f8434343188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000466459
RDX: 0000000020000200 RSI: 00000000400448dd RDI: 0000000000000005
RBP: 00000000004bf9fb R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007ffce5d8b6df R14: 00007f8434343300 R15: 0000000000022000

Allocated by task 3547:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 __do_kmalloc mm/slab.c:3720 [inline]
 __kmalloc+0x15a/0x400 mm/slab.c:3729
 kmalloc include/linux/slab.h:493 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 __alloc_workqueue_key+0x10e/0x1080 kernel/workqueue.c:4003
 hci_register_dev+0x1af/0x8f0 net/bluetooth/hci_core.c:3101
 __vhci_create_device+0x28d/0x540 drivers/bluetooth/hci_vhci.c:139
 vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline]
 vhci_open_timeout+0x35/0x50 drivers/bluetooth/hci_vhci.c:319
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Freed by task 7:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 __rcu_reclaim kernel/rcu/rcu.h:195 [inline]
 rcu_do_batch kernel/rcu/tree.c:2699 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
 rcu_process_callbacks+0x780/0x1180 kernel/rcu/tree.c:2946
 __do_softirq+0x24d/0x9ff kernel/softirq.c:288

The buggy address belongs to the object at ffff8880b3d28800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 384 bytes inside of
 512-byte region [ffff8880b3d28800, ffff8880b3d28a00)
The buggy address belongs to the page:
page:ffffea0002cf4a00 count:1 mapcount:0 mapping:ffff8880b3d28080 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880b3d28080 0000000000000000 0000000100000006
raw: ffffea0002a98d20 ffffea0002a67320 ffff88813fe80940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880b3d28880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b3d28900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880b3d28980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b3d28a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880b3d28a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2021/04/13 08:36 linux-4.14.y 958e517f4e16 6a81331a .config log report syz KASAN: use-after-free Read in __queue_work
ci2-linux-4-14 2021/02/11 08:58 linux-4.14.y 2c8a3fceddf0 a52ee10a .config log report syz KASAN: use-after-free Read in __queue_work
ci2-linux-4-14 2020/08/03 15:05 linux-4.14.y 7f2c5eb458b8 96dd3623 .config log report syz
ci2-linux-4-14 2020/08/27 16:47 linux-4.14.y d7e78d08fa77 816e0689 .config log report
* Struck through repros no longer work on HEAD.