bisecting fixing commit since 174651bdf802a2139065e8e31ce950e2f3fc4a94 building syzkaller on f879db37f90dcefb681897d2e486c11d8298cb72 testing commit 174651bdf802a2139065e8e31ce950e2f3fc4a94 with gcc (GCC) 8.1.0 kernel signature: 60439001100b860cfe6f700b38187344e60d3bae 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_put run #6: crashed: KASAN: use-after-free Read in cdev_put run #7: crashed: KASAN: use-after-free Read in put_device 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 c7ecf3e3a71c216327980f26b1e895ce9b07ad31 testing commit c7ecf3e3a71c216327980f26b1e895ce9b07ad31 with gcc (GCC) 8.1.0 kernel signature: d1feb928efe54f947d3fa6a2133969a492340ddd all runs: crashed: KASAN: use-after-free Read in cdev_put revisions tested: 2, total time: 26m41.879351429s (build: 18m4.22379437s, test: 7m46.510714646s) the crash still happens on HEAD commit msg: Linux 4.19.92 crash: KASAN: use-after-free Read in cdev_put input: syz1 as /devices/virtual/input/input1358 input: syz1 as /devices/virtual/input/input1359 input: syz1 as /devices/virtual/input/input1360 input: syz1 as /devices/virtual/input/input1361 ================================================================== BUG: KASAN: use-after-free in cdev_put.part.0+0x43/0x50 fs/char_dev.c:373 Read of size 8 at addr ffff88808e5c2bb0 by task syz-executor.3/11860 CPU: 1 PID: 11860 Comm: syz-executor.3 Not tainted 4.19.92-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x123/0x177 lib/dump_stack.c:118 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 cdev_put.part.0+0x43/0x50 fs/char_dev.c:373 cdev_put fs/char_dev.c:372 [inline] chrdev_open+0x246/0x5c0 fs/char_dev.c:431 do_dentry_open+0x3f1/0x1010 fs/open.c:796 vfs_open+0x9a/0xc0 fs/open.c:905 do_last fs/namei.c:3418 [inline] path_openat+0x691/0x3c00 fs/namei.c:3534 kobject: 'event5' (000000004eed6b32): kobject_add_internal: parent: 'input1361', set: 'devices' do_filp_open+0x177/0x250 fs/namei.c:3564 kobject: 'event5' (000000004eed6b32): kobject_uevent_env do_sys_open+0x1dd/0x350 fs/open.c:1088 __do_sys_open fs/open.c:1106 [inline] __se_sys_open fs/open.c:1101 [inline] __x64_sys_open+0x79/0xb0 fs/open.c:1101 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x414411 Code: 75 14 b8 02 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 19 00 00 c3 48 83 ec 08 e8 0a fa ff ff 48 89 04 24 b8 02 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fa ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007f6dbea9c7a0 EFLAGS: 00000293 ORIG_RAX: 0000000000000002 kobject: 'event5' (000000004eed6b32): fill_kobj_path: path = '/devices/virtual/input/input1361/event5' RAX: ffffffffffffffda RBX: 6666666666666667 RCX: 0000000000414411 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007f6dbea9c850 RBP: 000000000075bf20 R08: 000000000000000f R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000293 R12: 00007f6dbea9d6d4 R13: 00000000004caabe R14: 00000000004e3ce8 R15: 00000000ffffffff Allocated by task 11860: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553 kmem_cache_alloc_trace+0x152/0x740 mm/slab.c:3625 kmalloc include/linux/slab.h:515 [inline] kzalloc include/linux/slab.h:709 [inline] evdev_connect+0x6e/0x490 drivers/input/evdev.c:1388 input_attach_handler+0x10c/0x180 drivers/input/input.c:1004 input_register_device.cold.21+0x90/0x1d5 drivers/input/input.c:2159 uinput_create_device drivers/input/misc/uinput.c:373 [inline] uinput_ioctl_handler.isra.10+0x86b/0x18d0 drivers/input/misc/uinput.c:878 uinput_ioctl+0x39/0x60 drivers/input/misc/uinput.c:1049 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:501 [inline] do_vfs_ioctl+0x196/0x10c0 fs/ioctl.c:688 ksys_ioctl+0x62/0x90 fs/ioctl.c:705 __do_sys_ioctl fs/ioctl.c:712 [inline] __se_sys_ioctl fs/ioctl.c:710 [inline] __x64_sys_ioctl+0x6e/0xb0 fs/ioctl.c:710 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 kobject: 'event5' (000000004eed6b32): kobject_uevent_env entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 11874: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528 __cache_free mm/slab.c:3503 [inline] kfree+0xcf/0x220 mm/slab.c:3822 evdev_free+0x4d/0x60 drivers/input/evdev.c:370 device_release+0x71/0x1d0 drivers/base/core.c:892 kobject_cleanup lib/kobject.c:662 [inline] kobject_release lib/kobject.c:691 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put.cold.11+0x229/0x27c lib/kobject.c:708 cdev_default_release+0x39/0x50 fs/char_dev.c:613 kobject_cleanup lib/kobject.c:662 [inline] kobject_release lib/kobject.c:691 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put.cold.11+0x229/0x27c lib/kobject.c:708 cdev_put.part.0+0x31/0x50 fs/char_dev.c:374 cdev_put fs/char_dev.c:372 [inline] chrdev_open+0x246/0x5c0 fs/char_dev.c:431 do_dentry_open+0x3f1/0x1010 fs/open.c:796 vfs_open+0x9a/0xc0 fs/open.c:905 do_last fs/namei.c:3418 [inline] path_openat+0x691/0x3c00 fs/namei.c:3534 do_filp_open+0x177/0x250 fs/namei.c:3564 do_sys_open+0x1dd/0x350 fs/open.c:1088 __do_sys_open fs/open.c:1106 [inline] __se_sys_open fs/open.c:1101 [inline] __x64_sys_open+0x79/0xb0 fs/open.c:1101 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff88808e5c25c0 which belongs to the cache kmalloc-2048 of size 2048 kobject: 'event5' (000000004eed6b32): fill_kobj_path: path = '/devices/virtual/input/input1361/event5' The buggy address is located 1520 bytes inside of 2048-byte region [ffff88808e5c25c0, ffff88808e5c2dc0) The buggy address belongs to the page: page:ffffea0002397080 count:1 mapcount:0 mapping:ffff88812c29cc40 index:0xffff88808e5c36c0 compound_mapcount: 0 flags: 0xfffe0000008100(slab|head) raw: 00fffe0000008100 ffffea00026b0288 ffffea00026bbf88 ffff88812c29cc40 raw: ffff88808e5c36c0 ffff88808e5c25c0 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88808e5c2a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808e5c2b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88808e5c2b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88808e5c2c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88808e5c2c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================