bisecting fixing commit since 4fccc2503536a564a4ba31a1d50439854201659f building syzkaller on 2ffa6679c4790a83f26a1b674ed34800e028fe2e testing commit 4fccc2503536a564a4ba31a1d50439854201659f with gcc (GCC) 8.1.0 kernel signature: f4d56351c59831bc9eebfeaae367363888ebe78d687d70538f9ef76e3b6879f3 run #0: crashed: KASAN: use-after-free Read in psock_map_pop run #1: crashed: KASAN: use-after-free Read in psock_map_pop run #2: crashed: KASAN: use-after-free Read in psock_map_pop run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK testing current HEAD 20b3a3dfdf6c55b50bbdc8e231a3dbf6bf965dc7 testing commit 20b3a3dfdf6c55b50bbdc8e231a3dbf6bf965dc7 with gcc (GCC) 8.1.0 kernel signature: 78453ce2671bdf25b316c451f34a846c71d896cb13ca4a0cbf16e467e690c2a0 run #0: crashed: KASAN: use-after-free Read in psock_map_pop run #1: OK run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK revisions tested: 2, total time: 39m16.727046324s (build: 18m53.911315507s, test: 19m24.204263888s) the crash still happens on HEAD commit msg: Linux 4.19.134 crash: KASAN: use-after-free Read in psock_map_pop ================================================================== BUG: KASAN: use-after-free in __lock_acquire+0x3426/0x4980 kernel/locking/lockdep.c:3294 Read of size 8 at addr ffff88808adf78c8 by task syz-executor.1/5992 CPU: 0 PID: 5992 Comm: syz-executor.1 Not tainted 4.19.134-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 spin_lock_bh include/linux/spinlock.h:334 [inline] psock_map_pop.isra.17+0x1f/0x1b0 kernel/bpf/sockmap.c:302 bpf_tcp_remove+0x435/0x960 kernel/bpf/sockmap.c:366 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:0x415fc1 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:00007ffc1889c5f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000415fc1 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005 RBP: 0000000000000001 R08: 00ffffffffffffff R09: 00ffffffffffffff R10: 00007ffc1889c6d0 R11: 0000000000000293 R12: 000000000076bf20 R13: 0000000000771120 R14: 0000000000023627 R15: 000000000076bf2c Allocated by task 6001: 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_node_trace+0x14c/0x730 mm/slab.c:3668 kmalloc_node include/linux/slab.h:553 [inline] kzalloc_node include/linux/slab.h:720 [inline] smap_init_psock kernel/bpf/sockmap.c:1636 [inline] __sock_map_ctx_update_elem.isra.24+0x40c/0xdf0 kernel/bpf/sockmap.c:1940 sock_hash_ctx_update_elem.isra.26+0x63a/0x1040 kernel/bpf/sockmap.c:2411 sock_hash_update_elem+0x1b6/0x390 kernel/bpf/sockmap.c:2495 map_update_elem+0x59c/0xb70 kernel/bpf/syscall.c:821 __do_sys_bpf kernel/bpf/syscall.c:2409 [inline] __se_sys_bpf kernel/bpf/syscall.c:2379 [inline] __x64_sys_bpf+0x224/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 14: 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 smap_gc_work+0x773/0xa80 kernel/bpf/sockmap.c:1629 process_one_work+0x830/0x1670 kernel/workqueue.c:2155 worker_thread+0x85/0xb60 kernel/workqueue.c:2298 kthread+0x324/0x3e0 kernel/kthread.c:246 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 The buggy address belongs to the object at ffff88808adf7680 which belongs to the cache kmalloc-1024 of size 1024 The buggy address is located 584 bytes inside of 1024-byte region [ffff88808adf7680, ffff88808adf7a80) The buggy address belongs to the page: page:ffffea00022b7d80 count:1 mapcount:0 mapping:ffff88812c29cac0 index:0xffff88808adf6900 compound_mapcount: 0 flags: 0xfffe0000008100(slab|head) raw: 00fffe0000008100 ffffea000255bf08 ffffea0002419008 ffff88812c29cac0 raw: ffff88808adf6900 ffff88808adf6000 0000000100000003 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88808adf7780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808adf7800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88808adf7880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88808adf7900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808adf7980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================