Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING: held lock freed in l2cap_chan_timeout
=========================
WARNING: held lock freed!
5.8.0-syzkaller #0 Not tainted
-------------------------
kworker/0:3/3992 is freeing memory ffff888095abb000-ffff888095abb7ff, with a lock still held there!
ffff888095abb520 (&chan->lock/1){+.+.}-{3:3}, at: l2cap_chan_lock include/net/bluetooth/l2cap.h:850 [inline]
ffff888095abb520 (&chan->lock/1){+.+.}-{3:3}, at: l2cap_chan_timeout+0x86/0x1e0 net/bluetooth/l2cap_core.c:426
4 locks held by kworker/0:3/3992:
#0: ffff8880aa426d38 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x6f4/0xfc0 kernel/workqueue.c:2242
#1: ffffc90005dd7d80 ((work_completion)(&(&chan->chan_timer)->work)){+.+.}-{0:0}, at: process_one_work+0x733/0xfc0 kernel/workqueue.c:2244
#2: ffff8880a2a62ad8 (&conn->chan_lock){+.+.}-{3:3}, at: l2cap_chan_timeout+0x4c/0x1e0 net/bluetooth/l2cap_core.c:422
#3: ffff888095abb520 (&chan->lock/1){+.+.}-{3:3}, at: l2cap_chan_lock include/net/bluetooth/l2cap.h:850 [inline]
#3: ffff888095abb520 (&chan->lock/1){+.+.}-{3:3}, at: l2cap_chan_timeout+0x86/0x1e0 net/bluetooth/l2cap_core.c:426
stack backtrace:
CPU: 0 PID: 3992 Comm: kworker/0:3 Not tainted 5.8.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events l2cap_chan_timeout
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1f0/0x31e lib/dump_stack.c:118
print_freed_lock_bug kernel/locking/lockdep.c:5755 [inline]
debug_check_no_locks_freed+0x7f4/0xa20 kernel/locking/lockdep.c:5788
kfree+0xf0/0x220 mm/slab.c:3754
l2cap_sock_destruct+0x4d/0xd0 net/bluetooth/l2cap_sock.c:1690
__sk_destruct+0x50/0x770 net/core/sock.c:1770
l2cap_chan_timeout+0x165/0x1e0 net/bluetooth/l2cap_core.c:438
process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:56 [inline]
BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:837 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:29 [inline]
BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x88/0x590 kernel/locking/mutex.c:1237
Read of size 8 at addr ffff888095abb4b8 by task kworker/0:3/3992
CPU: 0 PID: 3992 Comm: kworker/0:3 Not tainted 5.8.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events l2cap_chan_timeout
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1f0/0x31e lib/dump_stack.c:118
print_address_description+0x66/0x5a0 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report+0x132/0x1d0 mm/kasan/report.c:530
check_memory_region_inline mm/kasan/generic.c:183 [inline]
check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192
instrument_atomic_read include/linux/instrumented.h:56 [inline]
atomic64_read include/asm-generic/atomic-instrumented.h:837 [inline]
atomic_long_read include/asm-generic/atomic-long.h:29 [inline]
__mutex_unlock_slowpath+0x88/0x590 kernel/locking/mutex.c:1237
l2cap_chan_unlock include/net/bluetooth/l2cap.h:855 [inline]
l2cap_chan_timeout+0x16d/0x1e0 net/bluetooth/l2cap_core.c:440
process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
Allocated by task 8319:
save_stack mm/kasan/common.c:48 [inline]
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494
kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
l2cap_chan_create+0x4c/0x320 net/bluetooth/l2cap_core.c:450
l2cap_sock_alloc+0x136/0x1d0 net/bluetooth/l2cap_sock.c:1807
l2cap_sock_create+0x11f/0x550 net/bluetooth/l2cap_sock.c:1838
bt_sock_create+0x15b/0x220 net/bluetooth/af_bluetooth.c:130
__sock_create+0x5b3/0x8c0 net/socket.c:1427
sock_create net/socket.c:1478 [inline]
__sys_socket+0xde/0x2d0 net/socket.c:1520
__do_sys_socket net/socket.c:1529 [inline]
__se_sys_socket net/socket.c:1527 [inline]
__x64_sys_socket+0x76/0x80 net/socket.c:1527
do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 3992:
save_stack mm/kasan/common.c:48 [inline]
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0x114/0x170 mm/kasan/common.c:455
__cache_free mm/slab.c:3426 [inline]
kfree+0x10a/0x220 mm/slab.c:3757
l2cap_sock_destruct+0x4d/0xd0 net/bluetooth/l2cap_sock.c:1690
__sk_destruct+0x50/0x770 net/core/sock.c:1770
l2cap_chan_timeout+0x165/0x1e0 net/bluetooth/l2cap_core.c:438
process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
The buggy address belongs to the object at ffff888095abb000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1208 bytes inside of
2048-byte region [ffff888095abb000, ffff888095abb800)
The buggy address belongs to the page:
page:ffffea000256aec0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000256ae88 ffffea0002596748 ffff8880aa400e00
raw: 0000000000000000 ffff888095abb000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888095abb380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888095abb400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888095abb480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888095abb500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888095abb580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: 03787533 Fix "trying to register non-static key in l2cap_c..
git tree:
https://github.com/coiby/linux.git syzbot8_test1
console output:
https://syzkaller.appspot.com/x/log.txt?x=1109c815900000
kernel config:
https://syzkaller.appspot.com/x/.config?x=61ec43e42a83feae
dashboard link:
https://syzkaller.appspot.com/bug?extid=abfc0f5e668d4099af73