bisecting fixing commit since fbc5fe7a54d02e11972e3b2a5ddb6ffc88162c8f building syzkaller on f879db37f90dcefb681897d2e486c11d8298cb72 testing commit fbc5fe7a54d02e11972e3b2a5ddb6ffc88162c8f with gcc (GCC) 8.1.0 kernel signature: 0b98764763c524b83f39525d09a67386a10aaf90 run #0: crashed: KASAN: use-after-free Read in cdev_put run #1: crashed: KASAN: use-after-free Read in cdev_put run #2: crashed: KASAN: use-after-free Read in cdev_put run #3: crashed: KASAN: use-after-free Read in cdev_put run #4: crashed: KASAN: use-after-free Read in cdev_put run #5: crashed: KASAN: use-after-free Read in cdev_default_release run #6: crashed: KASAN: use-after-free Read in cdev_put run #7: crashed: KASAN: use-after-free Read in cdev_put run #8: crashed: KASAN: use-after-free Read in cdev_put run #9: crashed: KASAN: use-after-free Read in cdev_put testing current HEAD 6d0c334a400db31751c787c411e7187ab59a3f1d testing commit 6d0c334a400db31751c787c411e7187ab59a3f1d with gcc (GCC) 8.1.0 kernel signature: 2e0ad6612b260d0025ed0a2c9f5d073b1d03e8ab all runs: crashed: KASAN: use-after-free Read in cdev_put revisions tested: 2, total time: 26m59.761818243s (build: 16m52.659361682s, test: 9m13.980944403s) the crash still happens on HEAD commit msg: Linux 4.14.164 crash: KASAN: use-after-free Read in cdev_put input: syz1 as /devices/virtual/input/input3813 input: syz1 as /devices/virtual/input/input3814 input: syz1 as /devices/virtual/input/input3817 input: syz1 as /devices/virtual/input/input3819 ================================================================== BUG: KASAN: use-after-free in cdev_put.part.0+0x43/0x50 fs/char_dev.c:373 Read of size 8 at addr ffff88808d3118e8 by task syz-executor.5/18220 CPU: 1 PID: 18220 Comm: syz-executor.5 Not tainted 4.14.164-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0xf7/0x13b lib/dump_stack.c:58 print_address_description.cold.7+0x9/0x1c9 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report.cold.8+0x11a/0x2d3 mm/kasan/report.c:409 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 cdev_put.part.0+0x43/0x50 fs/char_dev.c:373 cdev_put fs/char_dev.c:372 [inline] chrdev_open+0x238/0x5b0 fs/char_dev.c:431 do_dentry_open+0x620/0xdb0 fs/open.c:777 vfs_open+0xfc/0x240 fs/open.c:891 do_last fs/namei.c:3425 [inline] path_openat+0xe6d/0x3b50 fs/namei.c:3566 do_filp_open+0x16b/0x220 fs/namei.c:3600 do_sys_open+0x1c2/0x340 fs/open.c:1084 input: syz1 as /devices/virtual/input/input3820 SYSC_open fs/open.c:1102 [inline] SyS_open+0x19/0x20 fs/open.c:1097 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x414411 RSP: 002b:00007f6844cb77a0 EFLAGS: 00000293 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 6666666666666667 RCX: 0000000000414411 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007f6844cb7850 RBP: 000000000075bf20 R08: 000000000000000f R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000293 R12: 00007f6844cb86d4 R13: 00000000004caabe R14: 00000000004e3ce8 R15: 00000000ffffffff Allocated by task 18169: 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+0xc7/0xe0 mm/kasan/kasan.c:551 kmem_cache_alloc_trace+0x152/0x7a0 mm/slab.c:3618 kmalloc include/linux/slab.h:488 [inline] kzalloc include/linux/slab.h:661 [inline] evdev_connect+0x6e/0x490 drivers/input/evdev.c:1383 input_attach_handler+0x10c/0x180 drivers/input/input.c:1004 input_register_device.cold.20+0x90/0x1d5 drivers/input/input.c:2161 uinput_create_device drivers/input/misc/uinput.c:324 [inline] uinput_ioctl_handler.isra.10+0x7a3/0x16c0 drivers/input/misc/uinput.c:839 uinput_ioctl+0x39/0x60 drivers/input/misc/uinput.c:1010 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0x180/0xfb0 fs/ioctl.c:684 SYSC_ioctl fs/ioctl.c:701 [inline] SyS_ioctl+0x74/0x80 fs/ioctl.c:692 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Freed by task 18217: 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:3496 [inline] kfree+0xcc/0x270 mm/slab.c:3815 evdev_free+0x4d/0x60 drivers/input/evdev.c:364 device_release+0x71/0x170 drivers/base/core.c:821 kobject_cleanup lib/kobject.c:646 [inline] kobject_release lib/kobject.c:675 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put.cold.11+0x22a/0x2aa lib/kobject.c:692 cdev_default_release+0x39/0x50 fs/char_dev.c:613 kobject_cleanup lib/kobject.c:646 [inline] kobject_release lib/kobject.c:675 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put.cold.11+0x22a/0x2aa lib/kobject.c:692 cdev_put.part.0+0x31/0x50 fs/char_dev.c:374 cdev_put fs/char_dev.c:372 [inline] chrdev_open+0x238/0x5b0 fs/char_dev.c:431 do_dentry_open+0x620/0xdb0 fs/open.c:777 vfs_open+0xfc/0x240 fs/open.c:891 do_last fs/namei.c:3425 [inline] path_openat+0xe6d/0x3b50 fs/namei.c:3566 do_filp_open+0x16b/0x220 fs/namei.c:3600 do_sys_open+0x1c2/0x340 fs/open.c:1084 SYSC_open fs/open.c:1102 [inline] SyS_open+0x19/0x20 fs/open.c:1097 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 The buggy address belongs to the object at ffff88808d311300 which belongs to the cache kmalloc-2048 of size 2048 The buggy address is located 1512 bytes inside of 2048-byte region [ffff88808d311300, ffff88808d311b00) The buggy address belongs to the page: page:ffffea000234c400 count:1 mapcount:0 mapping:ffff88808d310200 index:0x0 compound_mapcount: 0 flags: 0xfffe0000008100(slab|head) raw: 00fffe0000008100 ffff88808d310200 0000000000000000 0000000100000003 raw: ffffea00023c7b20 ffffea00023421a0 ffff8880aa800c40 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88808d311780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808d311800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88808d311880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88808d311900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808d311980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================