syzbot


KASAN: use-after-free Read in cdev_put

Status: auto-closed as invalid on 2020/07/24 11:02
Reported-by: syzbot+2af7aca9f40c4c773068@syzkaller.appspotmail.com
First crash: 763d, last: 760d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in cdev_put C done 6 894d 937d 1/1 fixed on 2020/02/12 05:05
linux-4.19 KASAN: use-after-free Read in cdev_put C error 4 898d 937d 0/1 upstream: reported C repro on 2019/11/30 06:54

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in kobject_put+0x296/0x2f0 lib/kobject.c:745
Read of size 1 at addr ffff88808e2391c4 by task syz-executor.1/11174

CPU: 0 PID: 11174 Comm: syz-executor.1 Not tainted 5.7.0-rc6-next-20200522-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+0x18f/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 kobject_put+0x296/0x2f0 lib/kobject.c:745
 cdev_put.part.0+0x32/0x50 fs/char_dev.c:365
 cdev_put+0x1b/0x30 fs/char_dev.c:363
 __fput+0x69b/0x880 fs/file_table.c:284
 task_work_run+0xf4/0x1b0 kernel/task_work.c:123
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x2fa/0x360 arch/x86/entry/common.c:165
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
 do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x416621
Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007fff6b522200 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 0000000000416621
RDX: 0000000000000000 RSI: 00000000000000d0 RDI: 0000000000000004
RBP: 0000000000000001 R08: 00000000551800d0 R09: 00000000551800d4
R10: 00007fff6b5222f0 R11: 0000000000000293 R12: 0000000000792bd0
R13: 000000000004e9c2 R14: ffffffffffffffff R15: 000000000078bf0c

Allocated by task 11177:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc mm/kasan/common.c:494 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:467
 kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 evdev_connect+0x80/0x4d0 drivers/input/evdev.c:1352
 input_attach_handler+0x194/0x200 drivers/input/input.c:1031
 input_register_device.cold+0xf5/0x246 drivers/input/input.c:2229
 uinput_create_device drivers/input/misc/uinput.c:364 [inline]
 uinput_ioctl_handler.isra.0+0x1210/0x1d80 drivers/input/misc/uinput.c:870
 vfs_ioctl fs/ioctl.c:48 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
 __do_sys_ioctl fs/ioctl.c:762 [inline]
 __se_sys_ioctl fs/ioctl.c:760 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 11174:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x109/0x2b0 mm/slab.c:3757
 device_release+0x71/0x200 drivers/base/core.c:1541
 kobject_cleanup lib/kobject.c:701 [inline]
 kobject_release lib/kobject.c:732 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x2f0 lib/kobject.c:749
 kobject_cleanup lib/kobject.c:701 [inline]
 kobject_release lib/kobject.c:732 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x2f0 lib/kobject.c:749
 cdev_put.part.0+0x32/0x50 fs/char_dev.c:365
 cdev_put+0x1b/0x30 fs/char_dev.c:363
 __fput+0x69b/0x880 fs/file_table.c:284
 task_work_run+0xf4/0x1b0 kernel/task_work.c:123
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x2fa/0x360 arch/x86/entry/common.c:165
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
 do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

The buggy address belongs to the object at ffff88808e239000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 452 bytes inside of
 2048-byte region [ffff88808e239000, ffff88808e239800)
The buggy address belongs to the page:
page:ffffea0002388e40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00029d3dc8 ffffea00027ec908 ffff8880aa000e00
raw: 0000000000000000 ffff88808e239000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808e239080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808e239100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88808e239180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff88808e239200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808e239280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2020/05/25 11:01 linux-next c11d28ab4a69 11284182 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/05/25 10:55 linux-next c11d28ab4a69 11284182 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/05/24 22:45 linux-next c11d28ab4a69 bd28eb9d .config log report
ci-upstream-linux-next-kasan-gce-root 2020/05/24 22:21 linux-next c11d28ab4a69 bd28eb9d .config log report
ci-upstream-linux-next-kasan-gce-root 2020/05/23 21:19 linux-next c11d28ab4a69 9682898d .config log report
ci-upstream-linux-next-kasan-gce-root 2020/05/22 17:13 linux-next c11d28ab4a69 9682898d .config log report