bisecting fixing commit since cb95712138ec5e480db5160b41172bbc6f6494cc building syzkaller on cef5ae6814696260ff58c538a1b6044af90c5979 testing commit cb95712138ec5e480db5160b41172bbc6f6494cc with gcc (GCC) 8.4.1 20210217 kernel signature: 9b18ca80919f5801857d441e22eb090b0b0b8a9a34d95381668c75c616aa0623 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: KASAN: slab-out-of-bounds Read in lock_sock_nested run #4: crashed: WARNING: locking bug in l2cap_sock_teardown_cb 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: KASAN: use-after-free Read in lock_sock_nested run #8: crashed: INFO: trying to register non-static key in l2cap_sock_teardown_cb run #9: crashed: KASAN: use-after-free Read in lock_sock_nested run #10: crashed: KASAN: slab-out-of-bounds Read in lock_sock_nested run #11: crashed: WARNING: locking bug in l2cap_sock_teardown_cb run #12: crashed: KASAN: use-after-free Read in lock_sock_nested run #13: crashed: KASAN: use-after-free Read in lock_sock_nested run #14: crashed: KASAN: use-after-free Read in lock_sock_nested run #15: crashed: KASAN: use-after-free Read in lock_sock_nested 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: use-after-free Read in lock_sock_nested run #19: crashed: KASAN: use-after-free Read in lock_sock_nested testing current HEAD ad347abe4a9876b1f65f408ab467137e88f77eb4 testing commit ad347abe4a9876b1f65f408ab467137e88f77eb4 with gcc (GCC) 10.2.1 20210217 kernel signature: 789cf6cbd7a9c17e10703cbf6f9335e8f2e7193b1663aa5d72aa68e3e56f88e9 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: BUG: spinlock bad magic in lock_sock_nested 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: use-after-free Read in lock_sock_nested run #7: crashed: KASAN: use-after-free Read in lock_sock_nested run #8: crashed: KASAN: use-after-free Read in lock_sock_nested run #9: crashed: KASAN: use-after-free Read in lock_sock_nested revisions tested: 2, total time: 21m5.201531134s (build: 12m6.26411021s, test: 8m2.659359602s) the crash still happens on HEAD commit msg: Merge tag 'trace-v5.13-rc5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace 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 ffff8881181190a0 by task kworker/0:6/6110 CPU: 0 PID: 6110 Comm: kworker/0:6 Not tainted 5.13.0-rc5-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:3065 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:2276 worker_thread+0x598/0xf80 kernel/workqueue.c:2422 kthread+0x36f/0x450 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Allocated by task 6097: 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 kvmalloc include/linux/mm.h:804 [inline] xt_alloc_table_info+0x26/0x70 net/netfilter/x_tables.c:1178 do_replace net/ipv6/netfilter/ip6_tables.c:1141 [inline] do_ip6t_set_ctl+0x411/0xbe0 net/ipv6/netfilter/ip6_tables.c:1638 nf_setsockopt+0x6a/0xc0 net/netfilter/nf_sockopt.c:101 tcp_setsockopt+0x10d/0x1ff0 net/ipv4/tcp.c:3656 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2117 __do_sys_setsockopt net/socket.c:2128 [inline] __se_sys_setsockopt net/socket.c:2125 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2125 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 6097: 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 __do_replace+0x593/0x8b0 net/ipv6/netfilter/ip6_tables.c:1103 do_replace net/ipv6/netfilter/ip6_tables.c:1156 [inline] do_ip6t_set_ctl+0x791/0xbe0 net/ipv6/netfilter/ip6_tables.c:1638 nf_setsockopt+0x6a/0xc0 net/netfilter/nf_sockopt.c:101 tcp_setsockopt+0x10d/0x1ff0 net/ipv4/tcp.c:3656 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2117 __do_sys_setsockopt net/socket.c:2128 [inline] __se_sys_setsockopt net/socket.c:2125 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2125 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae Last potentially related work creation: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_record_aux_stack+0x87/0xb0 mm/kasan/generic.c:345 __call_rcu kernel/rcu/tree.c:3038 [inline] call_rcu+0x118/0x7e0 kernel/rcu/tree.c:3113 netlink_release+0xafa/0x17d0 net/netlink/af_netlink.c:812 __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 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0xac8/0x25b0 kernel/exit.c:826 do_group_exit+0xe7/0x290 kernel/exit.c:923 __do_sys_exit_group kernel/exit.c:934 [inline] __se_sys_exit_group kernel/exit.c:932 [inline] __x64_sys_exit_group+0x35/0x40 kernel/exit.c:932 do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff888118119000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 160 bytes inside of 2048-byte region [ffff888118119000, ffff888118119800) The buggy address belongs to the page: page:00000000a792f02a refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118119 flags: 0x17ffe0000000200(slab|node=0|zone=2|lastcpupid=0x3fff) raw: 017ffe0000000200 ffffea00047ae508 ffffea00045e5a08 ffff888100040800 raw: 0000000000000000 ffff888118119000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888118118f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888118119000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888118119080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888118119100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888118119180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== INFO: trying to register non-static key. The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator. CPU: 0 PID: 6110 Comm: kworker/0:6 Tainted: G B 5.13.0-rc5-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 assign_lock_key kernel/locking/lockdep.c:937 [inline] register_lock_class+0x112a/0x1200 kernel/locking/lockdep.c:1249 __lock_acquire+0xfc/0x5050 kernel/locking/lockdep.c:4781 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:3065 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:2276 worker_thread+0x598/0xf80 kernel/workqueue.c:2422 kthread+0x36f/0x450 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 0 P4D 0 Oops: 0010 [#1] PREEMPT SMP KASAN CPU: 0 PID: 6110 Comm: kworker/0:6 Tainted: G B 5.13.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout RIP: 0010:0x0 Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. RSP: 0000:ffffc90000907b88 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff888118119000 RCX: ffffffff8699833c RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff888118119000 RBP: 000000000000006f R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff8b8d6017 R11: 0000000000000001 R12: 0000000000000000 R13: ffff88811eb94000 R14: ffff88811eb94110 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8881f6400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000101f50003 CR4: 00000000001706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: l2cap_sock_teardown_cb+0x316/0x3a0 net/bluetooth/l2cap_sock.c:1553 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:2276 worker_thread+0x598/0xf80 kernel/workqueue.c:2422 kthread+0x36f/0x450 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Modules linked in: CR2: 0000000000000000 ---[ end trace 29f7f301ff00238b ]--- RIP: 0010:0x0 Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. RSP: 0000:ffffc90000907b88 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffff888118119000 RCX: ffffffff8699833c RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff888118119000 RBP: 000000000000006f R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff8b8d6017 R11: 0000000000000001 R12: 0000000000000000 R13: ffff88811eb94000 R14: ffff88811eb94110 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8881f6400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000101f50003 CR4: 00000000001706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400