================================================================== BUG: KASAN: use-after-free in free_netdev+0x3a7/0x410 net/core/dev.c:9249 Read of size 8 at addr ffff8880a54789e0 by task syz-executor.1/7506 CPU: 1 PID: 7506 Comm: syz-executor.1 Not tainted 4.19.211-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1fc/0x2ef lib/dump_stack.c:118 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354 kasan_report mm/kasan/report.c:412 [inline] __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433 free_netdev+0x3a7/0x410 net/core/dev.c:9249 netdev_run_todo+0x89b/0xab0 net/core/dev.c:9002 rtnl_unlock net/core/rtnetlink.c:117 [inline] rtnetlink_rcv_msg+0x460/0xb80 net/core/rtnetlink.c:4783 netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463 netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline] netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351 netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:651 [inline] sock_sendmsg+0xc3/0x120 net/socket.c:661 ___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227 __sys_sendmsg net/socket.c:2265 [inline] __do_sys_sendmsg net/socket.c:2274 [inline] __se_sys_sendmsg net/socket.c:2272 [inline] __x64_sys_sendmsg+0x132/0x220 net/socket.c:2272 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7fbf1c0d95a9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fbf1a62b168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fbf1c1fa050 RCX: 00007fbf1c0d95a9 RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000004 RBP: 00007fbf1c1347b0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffdb3aa60f R14: 00007fbf1a62b300 R15: 0000000000022000 Allocated by task 7491: __do_kmalloc mm/slab.c:3727 [inline] __kmalloc+0x15a/0x3c0 mm/slab.c:3736 kmalloc include/linux/slab.h:520 [inline] sk_prot_alloc+0x1e2/0x2d0 net/core/sock.c:1483 sk_alloc+0x36/0xec0 net/core/sock.c:1537 tun_chr_open+0x7b/0x560 drivers/net/tun.c:3286 misc_open+0x372/0x4a0 drivers/char/misc.c:141 chrdev_open+0x266/0x770 fs/char_dev.c:423 do_dentry_open+0x4aa/0x1160 fs/open.c:796 do_last fs/namei.c:3421 [inline] path_openat+0x793/0x2df0 fs/namei.c:3537 do_filp_open+0x18c/0x3f0 fs/namei.c:3567 do_sys_open+0x3b3/0x520 fs/open.c:1085 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 7484: __cache_free mm/slab.c:3503 [inline] kfree+0xcc/0x210 mm/slab.c:3822 sk_prot_free net/core/sock.c:1520 [inline] __sk_destruct+0x684/0x8a0 net/core/sock.c:1602 sk_destruct net/core/sock.c:1617 [inline] __sk_free+0x165/0x3b0 net/core/sock.c:1628 sk_free+0x3b/0x50 net/core/sock.c:1639 sock_put include/net/sock.h:1713 [inline] __tun_detach+0xccb/0x1320 drivers/net/tun.c:750 tun_detach drivers/net/tun.c:762 [inline] tun_chr_close+0x10e/0x180 drivers/net/tun.c:3323 __fput+0x2ce/0x890 fs/file_table.c:278 task_work_run+0x148/0x1c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x251/0x2a0 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+0x538/0x620 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8880a5478340 which belongs to the cache kmalloc-4096 of size 4096 The buggy address is located 1696 bytes inside of 4096-byte region [ffff8880a5478340, ffff8880a5479340) The buggy address belongs to the page: page:ffffea0002951e00 count:1 mapcount:0 mapping:ffff88813bff0dc0 index:0x0 compound_mapcount: 0 flags: 0xfff00000008100(slab|head) raw: 00fff00000008100 ffffea000275a808 ffffea000176a188 ffff88813bff0dc0 raw: 0000000000000000 ffff8880a5478340 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a5478880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a5478900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880a5478980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880a5478a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a5478a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================