BUG: KASAN: use-after-free in free_netdev+0x31a/0x360 net/core/dev.c:8144 Read of size 8 at addr ffff8801ce17afa0 by task syzkaller338011/2982 CPU: 1 PID: 2982 Comm: syzkaller338011 Not tainted 4.14.0-rc2-next-20170928+ #31 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:16 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:52 print_address_description+0x73/0x250 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report+0x25b/0x340 mm/kasan/report.c:409 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 free_netdev+0x31a/0x360 net/core/dev.c:8144 netdev_run_todo+0x935/0xca0 net/core/dev.c:7892 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:106 tun_detach drivers/net/tun.c:665 [inline] tun_chr_close+0x49/0x60 drivers/net/tun.c:2830 __fput+0x333/0x7f0 fs/file_table.c:210 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x199/0x270 kernel/task_work.c:112 exit_task_work include/linux/task_work.h:21 [inline] do_exit+0x9c8/0x1b00 kernel/exit.c:865 do_group_exit+0x149/0x400 kernel/exit.c:968 SYSC_exit_group kernel/exit.c:979 [inline] SyS_exit_group+0x1d/0x20 kernel/exit.c:977 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x442aa8 RSP: 002b:00007ffc963e4328 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000442aa8 RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000 RBP: 0000000000000086 R08: 00000000000000e7 R09: ffffffffffffffd0 R10: 0000000000000000 R11: 0000000000000246 R12: 74656e2f7665642f R13: 0000000000401b80 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 2982: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 __do_kmalloc mm/slab.c:3726 [inline] __kmalloc+0x162/0x760 mm/slab.c:3735 kmalloc include/linux/slab.h:513 [inline] sk_prot_alloc+0x101/0x2a0 net/core/sock.c:1469 sk_alloc+0x89/0x700 net/core/sock.c:1525 tun_chr_open+0xec/0x490 drivers/net/tun.c:2799 misc_open+0x382/0x500 drivers/char/misc.c:153 chrdev_open+0x257/0x730 fs/char_dev.c:416 do_dentry_open+0x67f/0xd70 fs/open.c:752 vfs_open+0x107/0x230 fs/open.c:866 do_last fs/namei.c:3387 [inline] path_openat+0x1157/0x3520 fs/namei.c:3527 do_filp_open+0x25b/0x3b0 fs/namei.c:3562 do_sys_open+0x502/0x6d0 fs/open.c:1059 SYSC_open fs/open.c:1077 [inline] SyS_open+0x2d/0x40 fs/open.c:1072 entry_SYSCALL_64_fastpath+0x1f/0xbe Freed by task 2982: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3504 [inline] kfree+0xca/0x250 mm/slab.c:3821 sk_prot_free net/core/sock.c:1508 [inline] __sk_destruct+0x74a/0x910 net/core/sock.c:1587 sk_destruct+0x47/0x80 net/core/sock.c:1595 __sk_free+0x57/0x230 net/core/sock.c:1603 sk_free+0x2a/0x40 net/core/sock.c:1614 sock_put include/net/sock.h:1651 [inline] __tun_detach+0x75b/0x1570 drivers/net/tun.c:657 tun_detach drivers/net/tun.c:664 [inline] tun_chr_close+0x44/0x60 drivers/net/tun.c:2830 __fput+0x333/0x7f0 fs/file_table.c:210 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x199/0x270 kernel/task_work.c:112 exit_task_work include/linux/task_work.h:21 [inline] do_exit+0x9c8/0x1b00 kernel/exit.c:865 do_group_exit+0x149/0x400 kernel/exit.c:968 SYSC_exit_group kernel/exit.c:979 [inline] SyS_exit_group+0x1d/0x20 kernel/exit.c:977 entry_SYSCALL_64_fastpath+0x1f/0xbe The buggy address belongs to the object at ffff8801ce17a980 which belongs to the cache kmalloc-4096 of size 4096 The buggy address is located 1568 bytes inside of 4096-byte region [ffff8801ce17a980, ffff8801ce17b980) The buggy address belongs to the page: page:ffffea0007385e80 count:1 mapcount:0 mapping:ffff8801ce17a980 index:0x0 compound_mapcount: 0 flags: 0x200000000008100(slab|head) raw: 0200000000008100 ffff8801ce17a980 0000000000000000 0000000100000001 raw: ffffea00073864a0 ffffea0007385fa0 ffff8801dac00dc0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801ce17ae80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801ce17af00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8801ce17af80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8801ce17b000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801ce17b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================