================================================================== BUG: KASAN: use-after-free in sk_psock_unlink+0x4d8/0x700 net/core/sock_map.c:993 Read of size 4 at addr ffff8881c1662ad8 by task syz-executor0/12841 CPU: 0 PID: 12841 Comm: syz-executor0 Not tainted 4.20.0-rc6+ #151 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+0x244/0x39d lib/dump_stack.c:113 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432 sk_psock_unlink+0x4d8/0x700 net/core/sock_map.c:993 tcp_bpf_remove+0xd0/0x130 net/ipv4/tcp_bpf.c:512 tcp_bpf_close+0x1c6/0x4a0 net/ipv4/tcp_bpf.c:552 inet_release+0x104/0x1f0 net/ipv4/af_inet.c:428 __sock_release+0xd7/0x250 net/socket.c:579 sock_close+0x19/0x20 net/socket.c:1141 __fput+0x385/0xa30 fs/file_table.c:278 ____fput+0x15/0x20 fs/file_table.c:309 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x1ad6/0x26d0 kernel/exit.c:867 do_group_exit+0x177/0x440 kernel/exit.c:970 get_signal+0x8b0/0x1980 kernel/signal.c:2517 do_signal+0x9c/0x21c0 arch/x86/kernel/signal.c:816 exit_to_usermode_loop+0x2e5/0x380 arch/x86/entry/common.c:162 prepare_exit_to_usermode+0x342/0x3b0 arch/x86/entry/common.c:197 retint_user+0x8/0x18 RIP: 0033:0x457685 Code: 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 48 3d 01 f0 ff ff 0f 83 cb b3 fb ff 66 2e 0f 1f 84 00 00 00 00 00 48 85 ff 41 57 4d 89 cf 41 56 41 RSP: 002b:0000000020000100 EFLAGS: 00010217 RAX: 0000000000000000 RBX: 0000000000000005 RCX: 0000000000457679 RDX: 0000000020000180 RSI: 0000000020000100 RDI: 0000000000000000 RBP: 000000000072bf00 R08: 0000000020000380 R09: 0000000000000000 R10: 0000000020000200 R11: 0000000000000246 R12: 00007f1995c396d4 R13: 00000000004bdbdd R14: 00000000004cd580 R15: 00000000ffffffff Allocated by task 12799: 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/0x750 mm/slab.c:3620 kmalloc include/linux/slab.h:546 [inline] kzalloc include/linux/slab.h:741 [inline] sock_hash_alloc+0x1eb/0x5a0 net/core/sock_map.c:802 find_and_alloc_map kernel/bpf/syscall.c:129 [inline] map_create+0x3bd/0x1110 kernel/bpf/syscall.c:509 __do_sys_bpf kernel/bpf/syscall.c:2489 [inline] __se_sys_bpf kernel/bpf/syscall.c:2466 [inline] __x64_sys_bpf+0x303/0x520 kernel/bpf/syscall.c:2466 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 8528: 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:3498 [inline] kfree+0xcf/0x230 mm/slab.c:3817 sock_hash_free+0x450/0x640 net/core/sock_map.c:865 bpf_map_free_deferred+0xd9/0x110 kernel/bpf/syscall.c:290 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296 kthread+0x35a/0x440 kernel/kthread.c:246 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352 The buggy address belongs to the object at ffff8881c1662ac0 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 24 bytes inside of 512-byte region [ffff8881c1662ac0, ffff8881c1662cc0) The buggy address belongs to the page: page:ffffea0007059880 count:1 mapcount:0 mapping:ffff8881da800940 index:0x0 flags: 0x2fffc0000000200(slab) raw: 02fffc0000000200 ffffea00070b9b88 ffffea0007347b08 ffff8881da800940 raw: 0000000000000000 ffff8881c16620c0 0000000100000006 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881c1662980: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc ffff8881c1662a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8881c1662a80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ^ ffff8881c1662b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881c1662b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ------------[ cut here ]------------ downgrading a read lock WARNING: CPU: 0 PID: 12846 at kernel/locking/lockdep.c:3556 __lock_downgrade kernel/locking/lockdep.c:3556 [inline] WARNING: CPU: 0 PID: 12846 at kernel/locking/lockdep.c:3556 lock_downgrade+0x4d7/0x900 kernel/locking/lockdep.c:3819