syzbot


KASAN: use-after-free Read in dev_uevent

Status: upstream: reported C repro on 2023/03/07 19:30
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+dd213ac7f1cdb8fd8708@syzkaller.appspotmail.com
First crash: 411d, last: 22d
Bug presence (2)
Date Name Commit Repro Result
2023/05/04 upstream (ToT) 1a5304fecee5 C [report] KASAN: slab-use-after-free Read in dev_uevent
2024/04/13 upstream (ToT) 8f2c057754b2 C Failed due to an error; will retry later
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Read in dev_uevent 4 1061d 1124d 0/2 auto-closed as invalid on 2021/09/24 00:56
android-54 KASAN: use-after-free Read in dev_uevent (2) 2 903d 909d 0/2 auto-closed as invalid on 2022/03/01 02:09
android-6-1 KASAN: use-after-free Read in dev_uevent 6 116d 286d 0/2 auto-obsoleted due to no activity on 2024/03/27 01:05
android-5-10 KASAN: use-after-free Read in dev_uevent 1 886d 886d 0/2 auto-closed as invalid on 2022/02/16 03:05
upstream KASAN: use-after-free Read in dev_uevent kernel syz 54 430d 1403d 22/26 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Read in dev_uevent kernel C error 66 1d15h 411d 0/26 upstream: reported C repro on 2023/03/07 08:15
Fix bisection attempts (10)
Created Duration User Patch Repo Result
2024/03/31 02:44 2h53m bisect fix linux-6.1.y job log (0) log
2024/02/29 18:35 2h23m bisect fix linux-6.1.y job log (0) log
2024/01/21 04:53 2h07m bisect fix linux-6.1.y job log (0) log
2023/12/22 00:05 2h22m bisect fix linux-6.1.y job log (0) log
2023/11/21 19:58 2h20m bisect fix linux-6.1.y job log (0) log
2023/10/18 18:17 2h16m bisect fix linux-6.1.y job log (0) log
2023/09/14 09:23 3h02m bisect fix linux-6.1.y job log (0) log
2023/06/30 11:00 1h17m bisect fix linux-6.1.y job log (0) log
2023/05/25 16:13 1h11m bisect fix linux-6.1.y job log (0) log
2023/04/21 16:14 1h00m bisect fix linux-6.1.y job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline]
BUG: KASAN: use-after-free in string+0x218/0x2b0 lib/vsprintf.c:725
Read of size 1 at addr ffff888021e06e40 by task udevd/2998

CPU: 0 PID: 2998 Comm: udevd Not tainted 6.1.20-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 string_nocheck lib/vsprintf.c:643 [inline]
 string+0x218/0x2b0 lib/vsprintf.c:725
 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2800
 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665
 dev_uevent+0x3e8/0x8e0 drivers/base/core.c:2568
 uevent_show+0x196/0x300 drivers/base/core.c:2639
 dev_attr_show+0x50/0xb0 drivers/base/core.c:2342
 sysfs_kf_seq_show+0x32d/0x4b0 fs/sysfs/file.c:59
 seq_read_iter+0x43a/0xd10 fs/seq_file.c:230
 call_read_iter include/linux/fs.h:2199 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x7de/0xbe0 fs/read_write.c:470
 ksys_read+0x19c/0x2c0 fs/read_write.c:613
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fb0023258fe
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:00007ffd569dc468 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 000055bd446155d0 RCX: 00007fb0023258fe
RDX: 0000000000001000 RSI: 000055bd44618e80 RDI: 000000000000000c
RBP: 00007fb0023f2380 R08: 000000000000000c R09: 00007fb0023f5a60
R10: 0000000000000800 R11: 0000000000000246 R12: 000055bd446155d0
R13: 0000000000000d68 R14: 00007fb0023f1780 R15: 0000000000000d68
 </TASK>

Allocated by task 11172:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:553 [inline]
 raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:460 [inline]
 raw_ioctl+0x1ab1/0x3bf0 drivers/usb/gadget/legacy/raw_gadget.c:1250
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 11172:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:210 [inline]
 kref_put+0xb5/0x7c0 include/linux/kref.h:65
 raw_release+0x134/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424
 __fput+0x3b7/0x890 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0x6fb/0x2300 kernel/exit.c:869
 do_group_exit+0x202/0x2b0 kernel/exit.c:1019
 get_signal+0x16f7/0x17d0 kernel/signal.c:2858
 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:869
 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x60/0x2d0 kernel/entry/common.c:296
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888021e06e40
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff888021e06e40, ffff888021e06e60)

The buggy address belongs to the physical page:
page:ffffea0000878180 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888021e06ec0 pfn:0x21e06
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00007a7b88 ffffea0001e7c988 ffff888012441500
raw: ffff888021e06ec0 000000000040003f 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 8045916958, free_ts 6846917462
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3573/0x3700 mm/page_alloc.c:4291
 __alloc_pages+0x28d/0x7e0 mm/page_alloc.c:5558
 alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2120
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xa71/0x1080 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:954 [inline]
 __kmalloc+0x9e/0x1a0 mm/slab_common.c:968
 kmalloc include/linux/slab.h:558 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 rh_call_control drivers/usb/core/hcd.c:514 [inline]
 rh_urb_enqueue drivers/usb/core/hcd.c:848 [inline]
 usb_hcd_submit_urb+0x8f5/0x1de0 drivers/usb/core/hcd.c:1552
 usb_start_wait_urb+0x10f/0x510 drivers/usb/core/message.c:58
 usb_internal_control_msg drivers/usb/core/message.c:102 [inline]
 usb_control_msg+0x2ad/0x4c0 drivers/usb/core/message.c:153
 usb_get_descriptor+0xb3/0x3c0 drivers/usb/core/message.c:793
 usb_get_configuration+0x37f/0x4d60 drivers/usb/core/config.c:928
 usb_enumerate_device drivers/usb/core/hub.c:2407 [inline]
 usb_new_device+0x146/0x18e0 drivers/usb/core/hub.c:2545
 register_root_hub+0x271/0x560 drivers/usb/core/hcd.c:1017
 usb_add_hcd+0xc4e/0x1250 drivers/usb/core/hcd.c:2991
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0xfe1/0x1190 mm/page_alloc.c:3387
 free_unref_page+0x98/0x570 mm/page_alloc.c:3483
 __vunmap+0x834/0x9a0 mm/vmalloc.c:2713
 free_work+0x57/0x80 mm/vmalloc.c:97
 process_one_work+0x909/0x1380 kernel/workqueue.c:2289
 worker_thread+0xa5f/0x1210 kernel/workqueue.c:2436
 kthread+0x268/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff888021e06d00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
 ffff888021e06d80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
>ffff888021e06e00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
                                           ^
 ffff888021e06e80: fa fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff888021e06f00: 00 00 02 fc fc fc fc fc 00 00 03 fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/21 13:23 linux-6.1.y 7eaef76fbc46 7939252e .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_uevent
2023/03/20 20:28 linux-6.1.y 7eaef76fbc46 7939252e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_uevent
2023/03/07 19:30 linux-6.1.y 42616e0f09fb d7ea8bc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_uevent
2023/05/30 23:30 linux-6.1.y d2869ace6eeb df37c7f1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in dev_uevent
* Struck through repros no longer work on HEAD.