syzbot


KASAN: use-after-free Read in cdev_put

Status: upstream: reported C repro on 2019/11/30 06:54
Reported-by: syzbot+b6e307e2fb59e07244c0@syzkaller.appspotmail.com
First crash: 937d, last: 898d

Fix bisection: failed (bisect log)
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
upstream KASAN: use-after-free Read in cdev_put 6 760d 759d 0/22 auto-closed as invalid on 2020/07/24 11:02

Sample crash report:
input: syz1 as /devices/virtual/input/input104
input: syz1 as /devices/virtual/input/input105
input: syz1 as /devices/virtual/input/input106
input: syz1 as /devices/virtual/input/input107
==================================================================
BUG: KASAN: use-after-free in cdev_put.part.0+0x4c/0x50 fs/char_dev.c:373
Read of size 8 at addr ffff888088ed1bf0 by task syz-executor331/8130

CPU: 0 PID: 8130 Comm: syz-executor331 Not tainted 4.19.87-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 cdev_put.part.0+0x4c/0x50 fs/char_dev.c:373
 cdev_put fs/char_dev.c:372 [inline]
 chrdev_open+0x2c1/0x6b0 fs/char_dev.c:431
 do_dentry_open+0x4c3/0x1210 fs/open.c:796
 vfs_open+0xa0/0xd0 fs/open.c:905
 do_last fs/namei.c:3418 [inline]
 path_openat+0x10d7/0x45e0 fs/namei.c:3534
 do_filp_open+0x1a1/0x280 fs/namei.c:3564
 do_sys_open+0x3fe/0x550 fs/open.c:1088
 __do_sys_open fs/open.c:1106 [inline]
 __se_sys_open fs/open.c:1101 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1101
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x406581
Code: 75 14 b8 02 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 a4 18 00 00 c3 48 83 ec 08 e8 ea fa ff ff 48 89 04 24 b8 02 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 33 fb ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007fe37e584960 EFLAGS: 00000293 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000406581
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007fe37e584970
RBP: 6666666666666667 R08: 000000000000000f R09: 00007fe37e585700
R10: 00007fe37e5859d0 R11: 0000000000000293 R12: 00000000006ddc3c
R13: 0000000000000000 R14: 0000000000000000 R15: 00000000317a7973

Allocated by task 8098:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 evdev_connect+0x83/0x4d0 drivers/input/evdev.c:1388
 input_attach_handler+0x1a0/0x210 drivers/input/input.c:1004
 input_register_device.cold+0xda/0x22b drivers/input/input.c:2159
 uinput_create_device drivers/input/misc/uinput.c:373 [inline]
 uinput_ioctl_handler.isra.0+0x1035/0x1c50 drivers/input/misc/uinput.c:878
 uinput_ioctl+0x4a/0x60 drivers/input/misc/uinput.c:1049
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
kobject: 'event6' (00000000d2a4bc01): fill_kobj_path: path = '/devices/virtual/input/input107/event6'
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8123:
 save_stack+0x45/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+0x5e/0x70 drivers/input/evdev.c:370
 device_release+0x7b/0x210 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+0x289/0x2e6 lib/kobject.c:708
kobject: 'event6' (00000000d2a4bc01): kobject_uevent_env
 cdev_default_release+0x41/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+0x289/0x2e6 lib/kobject.c:708
 cdev_put.part.0+0x39/0x50 fs/char_dev.c:374
 cdev_put fs/char_dev.c:372 [inline]
 chrdev_open+0x2c1/0x6b0 fs/char_dev.c:431
 do_dentry_open+0x4c3/0x1210 fs/open.c:796
 vfs_open+0xa0/0xd0 fs/open.c:905
 do_last fs/namei.c:3418 [inline]
 path_openat+0x10d7/0x45e0 fs/namei.c:3534
 do_filp_open+0x1a1/0x280 fs/namei.c:3564
 do_sys_open+0x3fe/0x550 fs/open.c:1088
 __do_sys_open fs/open.c:1106 [inline]
 __se_sys_open fs/open.c:1101 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1101
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
kobject: 'event6' (00000000d2a4bc01): fill_kobj_path: path = '/devices/virtual/input/input107/event6'
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888088ed1600
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1520 bytes inside of
 2048-byte region [ffff888088ed1600, ffff888088ed1e00)
The buggy address belongs to the page:
page:ffffea000223b400 count:1 mapcount:0 mapping:ffff88812c31cc40 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002a11d08 ffffea00029f2c08 ffff88812c31cc40
kobject: '(null)' (000000005650c1b1): kobject_cleanup, parent 00000000d2a4bc01
raw: 0000000000000000 ffff888088ed0500 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888088ed1a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888088ed1b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888088ed1b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
kobject: '(null)' (000000005650c1b1): calling ktype release
 ffff888088ed1c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888088ed1c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
kobject: 'input105' (00000000ec05a364): kobject_uevent_env

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2019/12/02 06:32 linux-4.19.y 174651bdf802 f879db37 .config log report syz C
ci2-linux-4-19 2019/12/02 05:03 linux-4.19.y 174651bdf802 f879db37 .config log report syz C
ci2-linux-4-19 2019/11/30 05:53 linux-4.19.y 14260788bbb9 3a75be00 .config log report syz
ci2-linux-4-19 2020/01/08 21:39 linux-4.19.y 3d40d7117e35 ddc3e859 .config log report