bisecting fixing commit since 9a9de33a9dfaaf6628d63c56d58ea5cbfe707739 building syzkaller on 995b2a26be0e511c1696883fb8e89af0fc669676 testing commit 9a9de33a9dfaaf6628d63c56d58ea5cbfe707739 with gcc (GCC) 8.1.0 kernel signature: 313f39581d98caf7008a48a078c0deea98ae9dee35528194a37e7d7e7ea4e48d all runs: crashed: KASAN: use-after-free Read in bpf_tcp_remove testing current HEAD b94de4d19498b454645b72d08a05d32fa9074fb5 testing commit b94de4d19498b454645b72d08a05d32fa9074fb5 with gcc (GCC) 8.1.0 kernel signature: e938f38c6923eae7664954e3a670d930be08ebff1f027e078335b4cf6ca6cb4c run #0: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #1: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #2: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #3: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #4: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #5: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #6: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #7: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #8: crashed: KASAN: use-after-free Read in bpf_tcp_remove run #9: OK revisions tested: 2, total time: 34m29.648401885s (build: 16m38.235532203s, test: 16m54.824160348s) the crash still happens on HEAD commit msg: Linux 4.19.155 crash: KASAN: use-after-free Read in bpf_tcp_remove ================================================================== BUG: KASAN: use-after-free in __lock_acquire+0x3426/0x4980 kernel/locking/lockdep.c:3294 Read of size 8 at addr ffff8880a2ec18b8 by task syz-executor.0/16995 CPU: 1 PID: 16995 Comm: syz-executor.0 Not tainted 4.19.155-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+0x123/0x177 lib/dump_stack.c:118 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 __lock_acquire+0x3426/0x4980 kernel/locking/lockdep.c:3294 lock_acquire+0x173/0x3d0 kernel/locking/lockdep.c:3907 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168 bpf_tcp_remove+0x3e8/0x960 kernel/bpf/sockmap.c:335 bpf_tcp_close+0xd2/0x280 kernel/bpf/sockmap.c:403 inet_release+0xb4/0x1b0 net/ipv4/af_inet.c:427 inet6_release+0x46/0x60 net/ipv6/af_inet6.c:472 __sock_release+0xc2/0x290 net/socket.c:579 sock_close+0x10/0x20 net/socket.c:1140 __fput+0x249/0x7f0 fs/file_table.c:278 ____fput+0x9/0x10 fs/file_table.c:309 task_work_run+0x108/0x180 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x1a9/0x200 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x413/0x4e0 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x413511 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007ffe2cfb1d70 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000413511 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005 RBP: 0000000000000001 R08: ffffffffffffffff R09: ffffffffffffffff R10: 00007ffe2cfb1e50 R11: 0000000000000293 R12: 000000000075bf20 R13: 000000000002545d R14: 00000000007610a8 R15: ffffffffffffffff Allocated by task 17003: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553 kmem_cache_alloc_trace+0x152/0x740 mm/slab.c:3625 kmalloc include/linux/slab.h:515 [inline] kzalloc include/linux/slab.h:709 [inline] sock_map_alloc+0x16d/0x370 kernel/bpf/sockmap.c:1675 find_and_alloc_map kernel/bpf/syscall.c:130 [inline] map_create+0x2ab/0xd80 kernel/bpf/syscall.c:510 __do_sys_bpf kernel/bpf/syscall.c:2403 [inline] __se_sys_bpf kernel/bpf/syscall.c:2379 [inline] __x64_sys_bpf+0x1e1/0x3a0 kernel/bpf/syscall.c:2379 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 7604: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528 __cache_free mm/slab.c:3503 [inline] kfree+0xcf/0x220 mm/slab.c:3822 sock_map_remove_complete kernel/bpf/sockmap.c:1583 [inline] sock_map_free+0x26c/0x350 kernel/bpf/sockmap.c:1778 bpf_map_free_deferred+0xaf/0xe0 kernel/bpf/syscall.c:291 process_one_work+0x830/0x1670 kernel/workqueue.c:2155 worker_thread+0x85/0xb60 kernel/workqueue.c:2298 kthread+0x347/0x410 kernel/kthread.c:259 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 The buggy address belongs to the object at ffff8880a2ec1780 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 312 bytes inside of 512-byte region [ffff8880a2ec1780, ffff8880a2ec1980) The buggy address belongs to the page: page:ffffea00028bb040 count:1 mapcount:0 mapping:ffff88813bf1e940 index:0xffff8880a2ec1a00 flags: 0x1fffc0000000100(slab) raw: 01fffc0000000100 ffffea0002ae3288 ffffea0002acca08 ffff88813bf1e940 raw: ffff8880a2ec1a00 ffff8880a2ec1000 0000000100000003 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a2ec1780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a2ec1800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880a2ec1880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880a2ec1900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a2ec1980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================