syzbot


KASAN: use-after-free Read in set_de_name_and_namelen

Status: upstream: reported C repro on 2022/11/25 09:46
Subsystems: reiserfs (incorrect?)
Reported-by: syzbot+3969ffae9388a369bab8@syzkaller.appspotmail.com
First crash: 125d, last: 22d

Cause bisection: failed (error log, bisect log)

Sample crash report:
REISERFS (device loop0): Using r5 hash to sort names
REISERFS (device loop0): Created .reiserfs_priv - reserved for xattr storage.
==================================================================
BUG: KASAN: use-after-free in strlen+0x7d/0xa0 lib/string.c:495
Read of size 1 at addr ffff88806e8719cc by task syz-executor324/3630

CPU: 0 PID: 3630 Comm: syz-executor324 Not tainted 6.1.0-rc8-syzkaller-00148-g0d1409e4ff08 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15e/0x45d mm/kasan/report.c:395
 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
 strlen+0x7d/0xa0 lib/string.c:495
 __fortify_strlen include/linux/fortify-string.h:196 [inline]
 set_de_name_and_namelen+0x4c4/0x6a0 fs/reiserfs/namei.c:82
 search_by_entry_key+0x4f3/0x960 fs/reiserfs/namei.c:172
 reiserfs_readdir_inode+0x24f/0x13b0 fs/reiserfs/dir.c:98
 iterate_dir+0x56e/0x6f0 fs/readdir.c:65
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64 fs/readdir.c:354 [inline]
 __x64_sys_getdents64+0x13e/0x2c0 fs/readdir.c:354
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f54d86aeeb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd2e7f79b8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007f54d871ded0 RCX: 00007f54d86aeeb9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007ffd2e7f79c8 R08: 00007f54d871de40 R09: 00007f54d871de40
R10: 00000000000010e3 R11: 0000000000000246 R12: 00007ffd2e7f79d0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001ba1c40 refcount:1 mapcount:1 mapping:0000000000000000 index:0x31 pfn:0x6e871
memcg:ffff888140140000
anon flags: 0xfff000000a0014(uptodate|lru|mappedtodisk|swapbacked|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff000000a0014 ffffea0001ba1c08 ffffea0001ba1c88 ffff88807f607001
raw: 0000000000000031 0000000000000000 0000000100000000 ffff888140140000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 3632, tgid 3632 (udevd), ts 53481954747, free_ts 10561755503
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4291
 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5558
 __folio_alloc+0x16/0x40 mm/page_alloc.c:5590
 vma_alloc_folio+0x155/0x870 mm/mempolicy.c:2246
 alloc_page_vma include/linux/gfp.h:284 [inline]
 wp_page_copy+0x1eb/0x1ca0 mm/memory.c:3118
 do_wp_page+0x538/0x1930 mm/memory.c:3486
 handle_pte_fault mm/memory.c:4972 [inline]
 __handle_mm_fault+0x181b/0x3a40 mm/memory.c:5096
 handle_mm_fault+0x1cc/0x780 mm/memory.c:5217
 do_user_addr_fault+0x475/0x1210 arch/x86/mm/fault.c:1428
 handle_page_fault arch/x86/mm/fault.c:1519 [inline]
 exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1575
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
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+0x65c/0xd90 mm/page_alloc.c:1509
 free_unref_page_prepare mm/page_alloc.c:3387 [inline]
 free_unref_page+0x1d/0x4d0 mm/page_alloc.c:3483
 free_contig_range+0xb5/0x180 mm/page_alloc.c:9496
 destroy_args+0xa8/0x64c mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x2958/0x29e9 mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x141/0x780 init/main.c:1303
 do_initcall_level init/main.c:1376 [inline]
 do_initcalls init/main.c:1392 [inline]
 do_basic_setup init/main.c:1411 [inline]
 kernel_init_freeable+0x6ff/0x788 init/main.c:1631
 kernel_init+0x1e/0x1d0 init/main.c:1519
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff88806e871880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88806e871900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88806e871980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                              ^
 ffff88806e871a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88806e871a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Fix bisection attempts:
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-upstream-fs 2023/03/08 07:10 upstream 63355b9884b3 74a66371 .config console log report syz C
ci2-upstream-fs 2023/02/06 06:27 upstream d2d11f342b17 74a66371 .config console log report syz C
* Struck through repros no longer work on HEAD.
Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce-root 2022/12/10 04:51 upstream 0d1409e4ff08 67be1ae7 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] KASAN: use-after-free Read in set_de_name_and_namelen
ci2-upstream-fs 2022/11/25 04:30 upstream c3eb11fbb826 74a66371 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] KASAN: use-after-free Read in set_de_name_and_namelen
ci-upstream-linux-next-kasan-gce-root 2023/01/07 05:41 linux-next cc3c08b41a9c 1dac8c7a .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] KASAN: use-after-free Read in set_de_name_and_namelen
ci2-upstream-fs 2022/11/25 04:08 upstream c3eb11fbb826 74a66371 .config console log report info [disk image] [vmlinux] [kernel image] KASAN: use-after-free Read in set_de_name_and_namelen
* Struck through repros no longer work on HEAD.