Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: use-after-free Read in io_wqe_worker
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x40aa/0x55d0 kernel/locking/lockdep.c:4666
Read of size 8 at addr ffff88821af40818 by task io_wqe_worker-0/8399
CPU: 1 PID: 8399 Comm: io_wqe_worker-0 Not tainted 5.9.0-rc4-next-20200911-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x198/0x1fb lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
__lock_acquire+0x40aa/0x55d0 kernel/locking/lockdep.c:4666
lock_acquire+0x1f2/0xaa0 kernel/locking/lockdep.c:5398
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
_raw_spin_lock_irq+0x94/0xd0 kernel/locking/spinlock.c:167
io_wqe_worker+0xdb0/0x10d0 fs/io-wq.c:589
kthread+0x3af/0x4a0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
Allocated by task 8396:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
kasan_set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
kmem_cache_alloc_node_trace+0x19f/0x560 mm/slab.c:3594
kmalloc_node include/linux/slab.h:572 [inline]
kzalloc_node include/linux/slab.h:677 [inline]
io_wq_create+0x57b/0xa10 fs/io-wq.c:1064
io_init_wq_offload fs/io_uring.c:7750 [inline]
io_sq_offload_create fs/io_uring.c:7843 [inline]
io_uring_create fs/io_uring.c:9035 [inline]
io_uring_setup+0x243b/0x3060 fs/io_uring.c:9118
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 8334:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
__kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
__cache_free mm/slab.c:3418 [inline]
kfree+0x10e/0x2a0 mm/slab.c:3756
__io_wq_destroy fs/io-wq.c:1138 [inline]
io_wq_destroy+0x2af/0x460 fs/io-wq.c:1146
io_finish_async fs/io_uring.c:7154 [inline]
io_ring_ctx_free fs/io_uring.c:8218 [inline]
io_ring_exit_work+0x132/0x5f0 fs/io_uring.c:8301
process_one_work+0x933/0x15a0 kernel/workqueue.c:2269
worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
kthread+0x3af/0x4a0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
The buggy address belongs to the object at ffff88821af40800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 24 bytes inside of
1024-byte region [ffff88821af40800, ffff88821af40c00)
The buggy address belongs to the page:
page:00000000990a38ba refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21af40
flags: 0x57ffe0000000200(slab)
raw: 057ffe0000000200 ffffea0008619e48 ffffea0008619588 ffff8880aa040700
raw: 0000000000000000 ffff88821af40000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88821af40700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88821af40780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88821af40800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88821af40880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88821af40900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: d5b2251d Add linux-next specific files for 20200911
git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
console output:
https://syzkaller.appspot.com/x/log.txt?x=164ca255900000
kernel config:
https://syzkaller.appspot.com/x/.config?x=37b3426c77bda44c