bisecting fixing commit since 06a7a37be55e29961c9ba2abec4d07c8e0e21861 building syzkaller on bc15f7dbbc1c6e2042a7115b3fdacc0ada8c35e7 testing commit 06a7a37be55e29961c9ba2abec4d07c8e0e21861 with gcc (GCC) 8.4.1 20210217 kernel signature: c1a01bb8a89a1db1e66babf084771f7f9491dd15dad740d090c1360e6a072016 run #0: crashed: KASAN: use-after-free Read in lock_sock_nested run #1: crashed: KASAN: use-after-free Read in lock_sock_nested run #2: crashed: KASAN: use-after-free Read in lock_sock_nested run #3: crashed: WARNING: locking bug in l2cap_sock_teardown_cb run #4: crashed: KASAN: use-after-free Read in lock_sock_nested run #5: crashed: KASAN: use-after-free Read in lock_sock_nested run #6: crashed: KASAN: slab-out-of-bounds Read in lock_sock_nested run #7: crashed: INFO: trying to register non-static key in l2cap_sock_teardown_cb run #8: crashed: KASAN: use-after-free Read in lock_sock_nested run #9: crashed: WARNING: locking bug in l2cap_sock_teardown_cb run #10: crashed: KASAN: use-after-free Read in lock_sock_nested run #11: crashed: KASAN: use-after-free Read in lock_sock_nested run #12: crashed: KASAN: use-after-free Read in lock_sock_nested run #13: crashed: INFO: trying to register non-static key in l2cap_sock_teardown_cb run #14: crashed: KASAN: use-after-free Read in lock_sock_nested run #15: crashed: WARNING: locking bug in l2cap_sock_teardown_cb run #16: crashed: KASAN: use-after-free Read in lock_sock_nested run #17: crashed: KASAN: use-after-free Read in lock_sock_nested run #18: crashed: KASAN: slab-out-of-bounds Read in lock_sock_nested run #19: crashed: KASAN: use-after-free Read in lock_sock_nested testing current HEAD 440c3247cba3d9433ac435d371dd7927d68772a7 testing commit 440c3247cba3d9433ac435d371dd7927d68772a7 with gcc (GCC) 10.2.1 20210217 kernel signature: 67493e2763ceb76f0ca604a96ae70f6be669e9514e32d93252db4ea5457e6991 all runs: crashed: KASAN: use-after-free Read in lock_sock_nested revisions tested: 2, total time: 21m52.332975832s (build: 12m55.226985103s, test: 7m50.390328832s) the crash still happens on HEAD commit msg: net: ipa: memory region array is variable size crash: KASAN: use-after-free Read in lock_sock_nested ================================================================== BUG: KASAN: use-after-free in __lock_acquire+0x3ad2/0x5050 kernel/locking/lockdep.c:4772 Read of size 8 at addr ffff8881012db0a0 by task kworker/1:4/7371 CPU: 1 PID: 7371 Comm: kworker/1:4 Not tainted 5.12.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:79 [inline] dump_stack+0x10c/0x14b lib/dump_stack.c:120 print_address_description.constprop.0.cold+0x5b/0x2c6 mm/kasan/report.c:233 __kasan_report mm/kasan/report.c:419 [inline] kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:436 __lock_acquire+0x3ad2/0x5050 kernel/locking/lockdep.c:4772 lock_acquire kernel/locking/lockdep.c:5512 [inline] lock_acquire+0x212/0x850 kernel/locking/lockdep.c:5477 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:359 [inline] lock_sock_nested+0x39/0xf0 net/core/sock.c:3057 l2cap_sock_teardown_cb+0x83/0x3a0 net/bluetooth/l2cap_sock.c:1528 l2cap_chan_del+0x96/0x1010 net/bluetooth/l2cap_core.c:622 l2cap_chan_close+0xe2/0x9d0 net/bluetooth/l2cap_core.c:825 l2cap_chan_timeout+0x122/0x3a0 net/bluetooth/l2cap_core.c:436 process_one_work+0x84c/0x13b0 kernel/workqueue.c:2275 worker_thread+0x598/0xf80 kernel/workqueue.c:2421 kthread+0x36f/0x450 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Allocated by task 9300: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] ____kasan_kmalloc mm/kasan/common.c:507 [inline] __kasan_kmalloc+0x7a/0x90 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:246 [inline] __do_kmalloc mm/slab.c:3702 [inline] __kmalloc+0x229/0x460 mm/slab.c:3711 kmalloc include/linux/slab.h:561 [inline] sk_prot_alloc+0xee/0x200 net/core/sock.c:1703 sk_alloc+0x27/0x8d0 net/core/sock.c:1756 l2cap_sock_alloc.constprop.0+0x22/0x200 net/bluetooth/l2cap_sock.c:1813 l2cap_sock_create+0xb1/0x190 net/bluetooth/l2cap_sock.c:1859 bt_sock_create+0x11a/0x250 net/bluetooth/af_bluetooth.c:130 __sock_create+0x257/0x540 net/socket.c:1408 sock_create net/socket.c:1459 [inline] __sys_socket+0xd6/0x1a0 net/socket.c:1501 __do_sys_socket net/socket.c:1510 [inline] __se_sys_socket net/socket.c:1508 [inline] __x64_sys_socket+0x6a/0xb0 net/socket.c:1508 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 9300: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:357 ____kasan_slab_free mm/kasan/common.c:360 [inline] ____kasan_slab_free mm/kasan/common.c:325 [inline] __kasan_slab_free+0xb2/0xe0 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:212 [inline] __cache_free mm/slab.c:3445 [inline] kfree+0x111/0x2e0 mm/slab.c:3803 sk_prot_free net/core/sock.c:1739 [inline] __sk_destruct+0x4da/0x6c0 net/core/sock.c:1824 l2cap_sock_release+0x166/0x1c0 net/bluetooth/l2cap_sock.c:1397 __sock_release+0xbb/0x270 net/socket.c:599 sock_close+0xf/0x20 net/socket.c:1258 __fput+0x209/0x870 fs/file_table.c:280 task_work_run+0xc0/0x160 kernel/task_work.c:164 get_signal+0x14cb/0x1b50 kernel/signal.c:2591 arch_do_signal_or_restart+0x2a8/0x1f80 arch/x86/kernel/signal.c:789 handle_signal_work kernel/entry/common.c:147 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x202/0x280 kernel/entry/common.c:208 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline] syscall_exit_to_user_mode+0x40/0x80 kernel/entry/common.c:301 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:57 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff8881012db000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 160 bytes inside of 2048-byte region [ffff8881012db000, ffff8881012db800) The buggy address belongs to the page: page:00000000cde377eb refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1012db flags: 0x17ffe0000000200(slab|node=0|zone=2|lastcpupid=0x3fff) raw: 017ffe0000000200 ffffea00047fa7c8 ffffea0004419548 ffff888100040800 raw: 0000000000000000 ffff8881012db000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881012daf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881012db000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881012db080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881012db100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881012db180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 7371 at lib/refcount.c:28 refcount_warn_saturate+0x12b/0x140 lib/refcount.c:28 Modules linked in: CPU: 1 PID: 7371 Comm: kworker/1:4 Tainted: G B 5.12.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:refcount_warn_saturate+0x12b/0x140 lib/refcount.c:28 Code: 39 f3 03 0f 0b e9 53 ff ff ff 48 89 df e8 cd d4 47 fe e9 23 ff ff ff 48 c7 c7 a0 0d 13 88 c6 05 0d d0 df 06 01 e8 d0 39 f3 03 <0f> 0b e9 2c ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 41 RSP: 0018:ffffc900048f7cb8 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffff888119942018 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffffffff88134720 RDI: fffff5200091ef89 RBP: 0000000000000003 R08: 0000000000000001 R09: ffff8881f6530dc7 R10: ffffed103eca61b8 R11: 0000000063666572 R12: ffff8881012db060 R13: ffff88811fe9f4b8 R14: ffffffff8889a3e0 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8881f6500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f4776750000 CR3: 00000001026d2003 CR4: 00000000001706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: l2cap_sock_kill+0x95/0x110 net/bluetooth/l2cap_sock.c:1225 l2cap_chan_timeout+0x171/0x3a0 net/bluetooth/l2cap_core.c:438 process_one_work+0x84c/0x13b0 kernel/workqueue.c:2275 worker_thread+0x598/0xf80 kernel/workqueue.c:2421 kthread+0x36f/0x450 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 irq event stamp: 302010 hardirqs last enabled at (302009): [] __cancel_work kernel/workqueue.c:3234 [inline] hardirqs last enabled at (302009): [] cancel_delayed_work+0x24d/0x360 kernel/workqueue.c:3256 hardirqs last disabled at (302008): [] try_to_grab_pending kernel/workqueue.c:1241 [inline] hardirqs last disabled at (302008): [] __cancel_work kernel/workqueue.c:3227 [inline] hardirqs last disabled at (302008): [] cancel_delayed_work+0x2ba/0x360 kernel/workqueue.c:3256 softirqs last enabled at (301998): [] srcu_invoke_callbacks+0x20a/0x3c0 kernel/rcu/srcutree.c:1274 softirqs last disabled at (302010): [] spin_lock_bh include/linux/spinlock.h:359 [inline] softirqs last disabled at (302010): [] lock_sock_nested+0x39/0xf0 net/core/sock.c:3057 ---[ end trace 2f4b1809883c2ad0 ]---