================================================================== BUG: KASAN: use-after-free in sk_psock_unlink+0x4d8/0x700 net/core/sock_map.c:993 Read of size 4 at addr ffff8881ca1f5298 by task syz-executor0/9633 CPU: 0 PID: 9633 Comm: syz-executor0 Not tainted 4.20.0-rc5-next-20181207+ #163 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.4+0x9/0x1ff mm/kasan/report.c:187 kasan_report.cold.5+0x1b/0x39 mm/kasan/report.c:317 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134 sk_psock_unlink+0x4d8/0x700 net/core/sock_map.c:993 tcp_bpf_remove+0xd0/0x130 net/ipv4/tcp_bpf.c:523 tcp_bpf_close+0x1c6/0x4a0 net/ipv4/tcp_bpf.c:563 inet_release+0x104/0x1f0 net/ipv4/af_inet.c:428 __sock_release+0xd7/0x250 net/socket.c:580 sock_close+0x19/0x20 net/socket.c:1142 __fput+0x3bc/0xa90 fs/file_table.c:279 ____fput+0x15/0x20 fs/file_table.c:312 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113 get_signal+0x1558/0x1980 kernel/signal.c:2345 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 arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x457569 Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 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 c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007faf0eae4c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: 0000000000280000 RBX: 0000000000000006 RCX: 0000000000457569 RDX: fffffffffffffe6e RSI: 0000000020a88f88 RDI: 0000000000000003 RBP: 000000000072bf00 R08: 0000000020e68000 R09: 0000000000000010 R10: 0000000020000000 R11: 0000000000000246 R12: 00007faf0eae56d4 R13: 00000000004c406f R14: 00000000004d6758 R15: 00000000ffffffff Allocated by task 9647: save_stack+0x43/0xd0 mm/kasan/common.c:73 set_track mm/kasan/common.c:85 [inline] kasan_kmalloc+0xcb/0xd0 mm/kasan/common.c:482 kmem_cache_alloc_trace+0x154/0x740 mm/slab.c:3607 kmalloc include/linux/slab.h:545 [inline] kzalloc include/linux/slab.h:740 [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:2524 [inline] __se_sys_bpf kernel/bpf/syscall.c:2501 [inline] __x64_sys_bpf+0x303/0x520 kernel/bpf/syscall.c:2501 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 12: save_stack+0x43/0xd0 mm/kasan/common.c:73 set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/common.c:444 kasan_slab_free+0xe/0x10 mm/kasan/common.c:452 __cache_free mm/slab.c:3485 [inline] kfree+0xcf/0x230 mm/slab.c:3804 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 ffff8881ca1f5280 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 24 bytes inside of 512-byte region [ffff8881ca1f5280, ffff8881ca1f5480) The buggy address belongs to the page: page:ffffea0007287d40 count:1 mapcount:0 mapping:ffff8881da800940 index:0x0 flags: 0x2fffc0000000200(slab) raw: 02fffc0000000200 ffffea0007197188 ffffea000709a748 ffff8881da800940 raw: 0000000000000000 ffff8881ca1f5000 0000000100000006 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881ca1f5180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881ca1f5200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8881ca1f5280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881ca1f5300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881ca1f5380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================