BUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5028 CPU: 2 PID: 7669 Comm: syzkaller550482 Not tainted 4.13.0-rc5-next-20170817+ #5 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 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_double_free+0x55/0x80 mm/kasan/report.c:333 kasan_slab_free+0xa3/0xc0 mm/kasan/kasan.c:514 __cache_free mm/slab.c:3503 [inline] kfree+0xca/0x250 mm/slab.c:3820 selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5028 security_tun_dev_free_security+0x48/0x80 security/security.c:1502 tun_set_iff drivers/net/tun.c:2084 [inline] __tun_chr_ioctl+0x2cb5/0x3d20 drivers/net/tun.c:2259 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2504 vfs_ioctl fs/ioctl.c:45 [inline] do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:685 SYSC_ioctl fs/ioctl.c:700 [inline] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x439729 RSP: 002b:00007ffcb9311968 EFLAGS: 00000217 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000439729 RDX: 0000000020533000 RSI: 00000000400454ca RDI: 0000000000000005 RBP: 0000000000009778 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000000000fd R11: 0000000000000217 R12: 0000000000000000 R13: 0000000000402040 R14: 00000000004020d0 R15: 0000000000000000 Allocated by task 7669: 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 kmem_cache_alloc_trace+0x136/0x750 mm/slab.c:3627 kmalloc include/linux/slab.h:493 [inline] kzalloc include/linux/slab.h:666 [inline] selinux_tun_dev_alloc_security+0x49/0x170 security/selinux/hooks.c:5017 security_tun_dev_alloc_security+0x6d/0xa0 security/security.c:1496 tun_set_iff drivers/net/tun.c:2039 [inline] __tun_chr_ioctl+0x1730/0x3d20 drivers/net/tun.c:2259 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2504 vfs_ioctl fs/ioctl.c:45 [inline] do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:685 SYSC_ioctl fs/ioctl.c:700 [inline] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691 entry_SYSCALL_64_fastpath+0x1f/0xbe Freed by task 7669: 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:3503 [inline] kfree+0xca/0x250 mm/slab.c:3820 selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5028 security_tun_dev_free_security+0x48/0x80 security/security.c:1502 tun_free_netdev+0x13b/0x1b0 drivers/net/tun.c:1763 register_netdevice+0x92b/0xf40 net/core/dev.c:7646 tun_set_iff drivers/net/tun.c:2059 [inline] __tun_chr_ioctl+0x1caf/0x3d20 drivers/net/tun.c:2259 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2504 vfs_ioctl fs/ioctl.c:45 [inline] do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:685 SYSC_ioctl fs/ioctl.c:700 [inline] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691 entry_SYSCALL_64_fastpath+0x1f/0xbe The buggy address belongs to the object at ffff88006a8e9000 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88006a8e9000, ffff88006a8e9020) The buggy address belongs to the page: page:ffffea0001aa3a40 count:1 mapcount:0 mapping:ffff88006a8e9000 index:0xffff88006a8e9fc1 flags: 0x500000000000100(slab) raw: 0500000000000100 ffff88006a8e9000 ffff88006a8e9fc1 0000000100000028 raw: ffffea0001b21160 ffffea0001b3dd20 ffff88003e8001c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88006a8e8f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88006a8e8f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88006a8e9000: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff88006a8e9080: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88006a8e9100: 05 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================