================================================================== BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3212 [inline] BUG: KASAN: double-free or invalid-free in kfree+0xc3/0x290 mm/slub.c:4200 CPU: 0 PID: 6740 Comm: syz-executor.4 Not tainted 5.10.135-syzkaller-01839-g30abcdabf21e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x81/0x3c0 mm/kasan/report.c:233 kasan_report_invalid_free+0x58/0x90 mm/kasan/report.c:358 ____kasan_slab_free+0x139/0x160 mm/kasan/common.c:362 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1604 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630 slab_free mm/slub.c:3212 [inline] kfree+0xc3/0x290 mm/slub.c:4200 selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5530 security_tun_dev_free_security+0x4d/0x90 security/security.c:2263 tun_free_netdev+0xbd/0x1c0 drivers/net/tun.c:2277 netdev_run_todo+0xbcd/0xe10 net/core/dev.c:10304 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:112 __tun_chr_ioctl+0x8ca/0x2130 drivers/net/tun.c:3362 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:3371 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 RIP: 0033:0x7f65a1446279 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:00007f65a057a168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f65a1559120 RCX: 00007f65a1446279 RDX: 0000000020000200 RSI: 00000000400454ca RDI: 0000000000000003 RBP: 00007f65a14a0189 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff7a65273f R14: 00007f65a057a300 R15: 0000000000022000 Allocated by task 6740: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:269 [inline] kmem_cache_alloc_trace+0x1dd/0x330 mm/slub.c:2983 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:664 [inline] selinux_tun_dev_alloc_security+0x51/0x140 security/selinux/hooks.c:5519 security_tun_dev_alloc_security+0x50/0xb0 security/security.c:2257 tun_set_iff+0x944/0x1100 drivers/net/tun.c:2795 __tun_chr_ioctl+0x8ab/0x2130 drivers/net/tun.c:3095 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:3371 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 Freed by task 6740: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1604 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630 slab_free mm/slub.c:3212 [inline] kfree+0xc3/0x290 mm/slub.c:4200 selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5530 security_tun_dev_free_security+0x4d/0x90 security/security.c:2263 tun_set_iff+0xc98/0x1100 drivers/net/tun.c:2850 __tun_chr_ioctl+0x8ab/0x2130 drivers/net/tun.c:3095 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:3371 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 The buggy address belongs to the object at ffff88810b5c3028 which belongs to the cache kmalloc-8 of size 8 The buggy address is located 0 bytes inside of 8-byte region [ffff88810b5c3028, ffff88810b5c3030) The buggy address belongs to the page: page:ffffea00042d70c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88810b5c3eb0 pfn:0x10b5c3 flags: 0x8000000000000200(slab) raw: 8000000000000200 ffffea0004001600 0000001700000017 ffff888100043c80 raw: ffff88810b5c3eb0 0000000080660065 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 127, ts 2976411818, free_ts 2946266324 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2385 [inline] prep_new_page mm/page_alloc.c:2391 [inline] get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4071 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5121 alloc_slab_page mm/slub.c:1815 [inline] allocate_slab+0x78/0x540 mm/slub.c:1817 new_slab mm/slub.c:1878 [inline] new_slab_objects mm/slub.c:2636 [inline] ___slab_alloc+0x131/0x2e0 mm/slub.c:2800 __slab_alloc+0x63/0xa0 mm/slub.c:2840 slab_alloc_node mm/slub.c:2922 [inline] slab_alloc mm/slub.c:2964 [inline] __kmalloc_track_caller+0x23e/0x350 mm/slub.c:4545 kmemdup_nul+0x2a/0xa0 mm/util.c:154 vfs_parse_fs_string+0x169/0x2a0 fs/fs_context.c:155 do_new_mount+0x22c/0xad0 fs/namespace.c:2893 path_mount+0x58d/0xce0 fs/namespace.c:3229 do_mount fs/namespace.c:3242 [inline] __do_sys_mount fs/namespace.c:3450 [inline] __se_sys_mount+0x2d2/0x3c0 fs/namespace.c:3427 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3427 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 page last free stack trace: reset_page_owner include/linux/page_owner.h:28 [inline] free_pages_prepare mm/page_alloc.c:1331 [inline] free_pcp_prepare+0x18c/0x1c0 mm/page_alloc.c:1405 free_unref_page_prepare mm/page_alloc.c:3291 [inline] free_unref_page mm/page_alloc.c:3345 [inline] free_the_page mm/page_alloc.c:5180 [inline] __free_pages+0x390/0x570 mm/page_alloc.c:5189 __vunmap+0x846/0x980 mm/vmalloc.c:2275 __vfree mm/vmalloc.c:2323 [inline] vfree+0x5c/0x80 mm/vmalloc.c:2354 sel_write_load+0x235/0x540 security/selinux/selinuxfs.c:667 vfs_write+0x369/0xf40 fs/read_write.c:603 ksys_write+0x198/0x2c0 fs/read_write.c:658 __do_sys_write fs/read_write.c:670 [inline] __se_sys_write fs/read_write.c:667 [inline] __x64_sys_write+0x7b/0x90 fs/read_write.c:667 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 Memory state around the buggy address: ffff88810b5c2f00: fc 00 00 00 00 00 00 00 00 00 fc fc fc fc 00 00 ffff88810b5c2f80: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc >ffff88810b5c3000: 04 fc fc fc fc fa fc fc fc fc 00 fc fc fc fc 00 ^ ffff88810b5c3080: fc fc fc fc 00 fc fc fc fc fa fc fc fc fc fa fc ffff88810b5c3100: fc fc fc fa fc fc fc fc fa fc fc fc fc fa fc fc ==================================================================