syzbot


KASAN: use-after-free Read in dev_uevent

Status: auto-closed as invalid on 2022/02/16 03:05
Reported-by: syzbot+dad93410df6ed476774e@syzkaller.appspotmail.com
First crash: 884d, last: 884d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in dev_uevent origin:upstream C 4 20d 409d 0/3 upstream: reported C repro on 2023/03/07 19:30
android-54 KASAN: use-after-free Read in dev_uevent 4 1059d 1123d 0/2 auto-closed as invalid on 2021/09/24 00:56
android-54 KASAN: use-after-free Read in dev_uevent (2) 2 901d 907d 0/2 auto-closed as invalid on 2022/03/01 02:09
android-6-1 KASAN: use-after-free Read in dev_uevent 6 114d 285d 0/2 auto-obsoleted due to no activity on 2024/03/27 01:05
upstream KASAN: use-after-free Read in dev_uevent kernel syz 54 428d 1401d 22/26 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Read in dev_uevent kernel C error 66 2h41m 410d 0/26 upstream: reported C repro on 2023/03/07 08:15

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_uevent+0x3dd/0x730 drivers/base/core.c:2206
Read of size 8 at addr ffff888101bda058 by task udevd/406

CPU: 0 PID: 406 Comm: udevd Not tainted 5.10.77-syzkaller-01258-g76698ea35fd3 #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_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 dev_uevent+0x3dd/0x730 drivers/base/core.c:2206
 uevent_show+0x1a5/0x320 drivers/base/core.c:2277
 dev_attr_show+0x56/0xd0 drivers/base/core.c:1979
 sysfs_kf_seq_show+0x26b/0x400 fs/sysfs/file.c:61
 kernfs_seq_show+0x117/0x160 fs/kernfs/file.c:168
 seq_read_iter+0x459/0xd30 fs/seq_file.c:230
 kernfs_fop_read_iter+0x161/0x490 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:1941 [inline]
 new_sync_read fs/read_write.c:415 [inline]
 vfs_read+0x9d4/0xbe0 fs/read_write.c:496
 ksys_read+0x186/0x2b0 fs/read_write.c:634
 __do_sys_read fs/read_write.c:644 [inline]
 __se_sys_read fs/read_write.c:642 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:642
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f6e784d48fe
Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28
RSP: 002b:00007ffd2d45eaa8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 0000559d9155f320 RCX: 00007f6e784d48fe
RDX: 0000000000001000 RSI: 0000559d915cb7c0 RDI: 0000000000000008
RBP: 00007f6e785a1380 R08: 0000000000000008 R09: 00007f6e785a4a60
R10: 0000000000800000 R11: 0000000000000246 R12: 0000559d9155f320
R13: 0000000000000d68 R14: 00007f6e785a0780 R15: 0000000000000d68

Allocated by task 1918:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 kmem_cache_alloc_trace+0x210/0x3a0 mm/slub.c:2975
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 dev_new drivers/usb/gadget/legacy/raw_gadget.c:182 [inline]
 raw_open+0x8a/0x380 drivers/usb/gadget/legacy/raw_gadget.c:372
 misc_open+0x3ea/0x440 drivers/char/misc.c:141
 chrdev_open+0x5fb/0x680 fs/char_dev.c:414
 do_dentry_open+0x7a5/0x1090 fs/open.c:819
 vfs_open+0x73/0x80 fs/open.c:942
 do_open fs/namei.c:3327 [inline]
 path_openat+0x264d/0x3500 fs/namei.c:3444
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 1918:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
 ____kasan_slab_free+0x133/0x170 mm/kasan/common.c:360
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1596 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1622
 slab_free mm/slub.c:3204 [inline]
 kfree+0xd5/0x320 mm/slub.c:4192
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:214 [inline]
 kref_put+0x6a9/0x740 include/linux/kref.h:65
 raw_release+0x141/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:411
 __fput+0x348/0x7d0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0x70e/0x23a0 kernel/exit.c:813
 do_group_exit+0x16a/0x2d0 kernel/exit.c:910
 get_signal+0x133e/0x1f80 kernel/signal.c:2790
 arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805
 exit_to_user_mode_loop kernel/entry/common.c:161 [inline]
 exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191
 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266
 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888101bda000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 88 bytes inside of
 4096-byte region [ffff888101bda000, ffff888101bdb000)
The buggy address belongs to the page:
page:ffffea000406f600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x101bd8
head:ffffea000406f600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff888100042c00
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 406, ts 108641523831, free_ts 108534370668
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1807 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1809
 new_slab mm/slub.c:1870 [inline]
 new_slab_objects mm/slub.c:2629 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2792
 __slab_alloc mm/slub.c:2832 [inline]
 slab_alloc_node mm/slub.c:2914 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc_trace+0x278/0x3a0 mm/slub.c:2973
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 kernfs_iop_get_link+0x65/0x5c0 fs/kernfs/symlink.c:135
 pick_link fs/namei.c:1734 [inline]
 step_into+0x1127/0x1f10 fs/namei.c:1796
 open_last_lookups fs/namei.c:3276 [inline]
 path_openat+0x181a/0x3500 fs/namei.c:3441
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 __free_pages_ok+0xbe7/0xc20 mm/page_alloc.c:1611
 free_the_page mm/page_alloc.c:5167 [inline]
 __free_pages+0x2d6/0x4a0 mm/page_alloc.c:5173
 __free_slab+0xdf/0x1a0 mm/slub.c:1895
 free_slab mm/slub.c:1910 [inline]
 discard_slab mm/slub.c:1916 [inline]
 unfreeze_partials+0x17d/0x1b0 mm/slub.c:2410
 put_cpu_partial+0xc8/0x190 mm/slub.c:2446
 __slab_free+0x2eb/0x4e0 mm/slub.c:3096
 do_slab_free mm/slub.c:3192 [inline]
 ___cache_free+0x131/0x150 mm/slub.c:3211
 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146
 qlist_free_all mm/kasan/quarantine.c:165 [inline]
 kasan_quarantine_reduce+0x178/0x1d0 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2948 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2961
 ext4_alloc_inode+0x21/0x620 fs/ext4/super.c:1293
 alloc_inode fs/inode.c:234 [inline]
 new_inode_pseudo+0x65/0x220 fs/inode.c:930
 new_inode+0x28/0x1c0 fs/inode.c:959
 __ext4_new_inode+0x2f3/0x5a00 fs/ext4/ialloc.c:960
 ext4_symlink+0x4d1/0xf80 fs/ext4/namei.c:3448

Memory state around the buggy address:
 ffff888101bd9f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888101bd9f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888101bda000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff888101bda080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888101bda100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/18 03:01 android12-5.10-lts 76698ea35fd3 cafff8b6 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in dev_uevent
* Struck through repros no longer work on HEAD.