syzbot


KASAN: slab-out-of-bounds Read in seq_printf

Status: moderation: reported on 2025/01/26 09:47
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+85c269e93af9ee977d4e@syzkaller.appspotmail.com
First crash: 64d, last: 23d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KMSAN: uninit-value in seq_printf (2) fs C 99 1016d 1282d 0/28 auto-closed as invalid on 2022/09/30 02:43
upstream KMSAN: kernel-infoleak in __skb_datagram_iter net 68 548d 653d 23/28 fixed on 2023/09/28 17:51
upstream KMSAN: uninit-value in seq_printf fs 3 1939d 1968d 0/28 auto-closed as invalid on 2020/03/04 05:44

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in string_nocheck lib/vsprintf.c:632 [inline]
BUG: KASAN: slab-out-of-bounds in string+0x4a6/0x4f0 lib/vsprintf.c:714
Read of size 1 at addr ffff888035075a20 by task syz.1.712/9185

CPU: 1 UID: 0 PID: 9185 Comm: syz.1.712 Not tainted 6.13.0-syzkaller-01005-gb9d8a295ed6b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:489
 kasan_report+0xd9/0x110 mm/kasan/report.c:602
 string_nocheck lib/vsprintf.c:632 [inline]
 string+0x4a6/0x4f0 lib/vsprintf.c:714
 vsnprintf+0x4c8/0x1180 lib/vsprintf.c:2843
 seq_vprintf fs/seq_file.c:391 [inline]
 seq_printf+0x1a6/0x250 fs/seq_file.c:406
 input_devices_seq_show+0x20e/0x1130 drivers/input/input.c:1172
 traverse.part.0.constprop.0+0x104/0x640 fs/seq_file.c:111
 traverse fs/seq_file.c:98 [inline]
 seq_read_iter+0x934/0x12b0 fs/seq_file.c:195
 seq_read+0x39f/0x4e0 fs/seq_file.c:162
 pde_read fs/proc/inode.c:308 [inline]
 proc_reg_read+0x23d/0x330 fs/proc/inode.c:320
 do_loop_readv_writev fs/read_write.c:840 [inline]
 do_loop_readv_writev fs/read_write.c:828 [inline]
 vfs_readv+0x6bf/0x890 fs/read_write.c:1013
 do_preadv+0x1b1/0x270 fs/read_write.c:1125
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9b13785d29
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9b145f1038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f9b13976160 RCX: 00007f9b13785d29
RDX: 0000000000000001 RSI: 0000000020003780 RDI: 0000000000000008
RBP: 00007f9b13801b08 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000ffff R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f9b13976160 R15: 00007ffdfef419a8
 </TASK>

Allocated by task 8706:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __do_kmalloc_node mm/slub.c:4298 [inline]
 __kmalloc_noprof+0x21c/0x510 mm/slub.c:4310
 kmalloc_noprof include/linux/slab.h:905 [inline]
 tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x276/0x460 security/tomoyo/file.c:822
 security_inode_getattr+0x116/0x290 security/security.c:2372
 vfs_getattr fs/stat.c:243 [inline]
 vfs_statx_path+0x2b/0x310 fs/stat.c:283
 vfs_statx+0x11f/0x1c0 fs/stat.c:347
 vfs_fstatat+0x7b/0xf0 fs/stat.c:366
 __do_sys_newfstatat+0x98/0x120 fs/stat.c:530
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 8706:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:582
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2353 [inline]
 slab_free mm/slub.c:4613 [inline]
 kfree+0x14f/0x4b0 mm/slub.c:4761
 tomoyo_realpath_from_path+0x1ad/0x720 security/tomoyo/realpath.c:286
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x276/0x460 security/tomoyo/file.c:822
 security_inode_getattr+0x116/0x290 security/security.c:2372
 vfs_getattr fs/stat.c:243 [inline]
 vfs_statx_path+0x2b/0x310 fs/stat.c:283
 vfs_statx+0x11f/0x1c0 fs/stat.c:347
 vfs_fstatat+0x7b/0xf0 fs/stat.c:366
 __do_sys_newfstatat+0x98/0x120 fs/stat.c:530
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888035074000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 2592 bytes to the right of
 allocated 4096-byte region [ffff888035074000, ffff888035075000)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x35070
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801b042140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000
head: 00fff00000000040 ffff88801b042140 dead000000000122 0000000000000000
head: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000
head: 00fff00000000003 ffffea0000d41c01 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 8706, tgid 8706 (syz-executor), ts 385768035678, free_ts 385705829653
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1558
 prep_new_page mm/page_alloc.c:1566 [inline]
 get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3476
 __alloc_pages_noprof+0x221/0x2470 mm/page_alloc.c:4753
 alloc_pages_mpol_noprof+0x2c8/0x620 mm/mempolicy.c:2269
 alloc_slab_page mm/slub.c:2423 [inline]
 allocate_slab mm/slub.c:2589 [inline]
 new_slab+0x2c9/0x410 mm/slub.c:2642
 ___slab_alloc+0xd75/0x17a0 mm/slub.c:3830
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3920
 __slab_alloc_node mm/slub.c:3995 [inline]
 slab_alloc_node mm/slub.c:4156 [inline]
 __do_kmalloc_node mm/slub.c:4297 [inline]
 __kmalloc_noprof+0x2ec/0x510 mm/slub.c:4310
 kmalloc_noprof include/linux/slab.h:905 [inline]
 tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x276/0x460 security/tomoyo/file.c:822
 security_inode_getattr+0x116/0x290 security/security.c:2372
 vfs_getattr fs/stat.c:243 [inline]
 vfs_statx_path+0x2b/0x310 fs/stat.c:283
 vfs_statx+0x11f/0x1c0 fs/stat.c:347
 vfs_fstatat+0x7b/0xf0 fs/stat.c:366
 __do_sys_newfstatat+0x98/0x120 fs/stat.c:530
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
page last free pid 9077 tgid 9077 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_unref_page+0x661/0x1080 mm/page_alloc.c:2659
 __put_partials+0x14c/0x170 mm/slub.c:3157
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4119 [inline]
 slab_alloc_node mm/slub.c:4168 [inline]
 __do_kmalloc_node mm/slub.c:4297 [inline]
 __kmalloc_noprof+0x1cd/0x510 mm/slub.c:4310
 kmalloc_noprof include/linux/slab.h:905 [inline]
 tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x276/0x460 security/tomoyo/file.c:822
 security_inode_getattr+0x116/0x290 security/security.c:2372
 vfs_getattr fs/stat.c:243 [inline]
 vfs_fstat+0x4b/0xd0 fs/stat.c:265
 vfs_fstatat+0xbc/0xf0 fs/stat.c:364
 __do_sys_newfstatat+0x98/0x120 fs/stat.c:530
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888035075900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888035075980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888035075a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                               ^
 ffff888035075a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888035075b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/22 09:39 upstream b9d8a295ed6b da72ac06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-out-of-bounds Read in seq_printf
2025/03/05 02:54 upstream 48a5eed9ad58 c3901742 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kmsan-gce-root KMSAN: uninit-value in seq_printf
2025/02/03 21:23 upstream 2014c95afece a21a8419 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in seq_printf
* Struck through repros no longer work on HEAD.