BUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x15/0x20 security/selinux/hooks.c:5028 CPU: 2 PID: 3016 Comm: syzkaller140426 Not tainted 4.13.0-rc4-next-20170811 #2 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:1884 [inline] __tun_chr_ioctl+0x2cb5/0x3d20 drivers/net/tun.c:2059 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2304 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:0x439139 RSP: 002b:00007ffd44a10338 EFLAGS: 00000217 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 3ce0bf1bfd9aecc7 RCX: 0000000000439139 RDX: 0000000020533000 RSI: 00000000400454ca RDI: 0000000000000018 RBP: 4b5a842743666425 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000000000fd R11: 0000000000000217 R12: 0000001000003a8d R13: 74656e2f7665642f R14: 0000000000401e20 R15: 0000000000000000 Allocated by task 3016: 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:1839 [inline] __tun_chr_ioctl+0x1730/0x3d20 drivers/net/tun.c:2059 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2304 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 3016: 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:1563 register_netdevice+0x92b/0xf40 net/core/dev.c:7645 tun_set_iff drivers/net/tun.c:1859 [inline] __tun_chr_ioctl+0x1caf/0x3d20 drivers/net/tun.c:2059 tun_chr_ioctl+0x2a/0x40 drivers/net/tun.c:2304 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 ffff88006a4d8f80 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88006a4d8f80, ffff88006a4d8fa0) The buggy address belongs to the page: page:ffffea0001a93600 count:1 mapcount:0 mapping:ffff88006a4d8000 index:0xffff88006a4d8fc1 flags: 0x500000000000100(slab) raw: 0500000000000100 ffff88006a4d8000 ffff88006a4d8fc1 000000010000000d raw: ffffea0001a91ae0 ffffea0001b36860 ffff88003e8001c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88006a4d8e80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88006a4d8f00: fb fb fb fb fc fc fc fc 00 03 fc fc fc fc fc fc >ffff88006a4d8f80: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88006a4d9000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88006a4d9080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================