syzbot


KASAN: use-after-free Read in reiserfs_readdir_inode

Status: upstream: reported C repro on 2023/05/07 23:16
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+570b04e6236b9f102b59@syzkaller.appspotmail.com
First crash: 361d, last: 22d
Bug presence (1)
Date Name Commit Repro Result
2023/05/11 upstream (ToT) 80e62bc8487b C [report] KASAN: use-after-free Read in reiserfs_readdir_inode
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream BUG: unable to handle kernel paging request in reiserfs_readdir_inode reiserfs C error done 11 118d 484d 26/26 fixed on 2024/02/21 18:23
linux-5.15 KASAN: out-of-bounds Read in reiserfs_readdir_inode origin:upstream C 1 3d23h 369d 0/3 upstream: reported C repro on 2023/04/30 22:45
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2024/04/11 13:26 5h29m bisect fix linux-6.1.y job log (0) log
2024/03/10 06:37 1h21m bisect fix linux-6.1.y job log (0) log
2024/02/01 00:19 1h44m bisect fix linux-6.1.y job log (0) log
2023/12/29 00:16 1h08m bisect fix linux-6.1.y job log (0) log
2023/11/27 02:03 1h10m bisect fix linux-6.1.y job log (0) log
2023/10/26 23:29 1h31m bisect fix linux-6.1.y job log (0) log
2023/09/22 21:03 1h09m bisect fix linux-6.1.y job log (0) log
2023/07/11 19:49 3h14m bisect fix linux-6.1.y job log (0) log
2023/06/06 23:15 48m bisect fix linux-6.1.y job log (0) log

Sample crash report:
REISERFS (device loop0): journal params: device loop0, size 512, journal first block 18, max trans len 256, max batch 225, max commit age 30, max trans age 30
REISERFS (device loop0): checking transaction log (loop0)
REISERFS (device loop0): Using r5 hash to sort names
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: use-after-free in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
BUG: KASAN: use-after-free in test_bit_le include/asm-generic/bitops/le.h:21 [inline]
BUG: KASAN: use-after-free in reiserfs_readdir_inode+0x5d8/0x14c0 fs/reiserfs/dir.c:147
Read of size 8 at addr ffff8880706a7000 by task syz-executor463/3541

CPU: 1 PID: 3541 Comm: syz-executor463 Not tainted 6.1.27-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/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
 kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
 test_bit_le include/asm-generic/bitops/le.h:21 [inline]
 reiserfs_readdir_inode+0x5d8/0x14c0 fs/reiserfs/dir.c:147
 iterate_dir+0x224/0x560
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354
 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:0x7fb60f4c32e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 d1 17 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:00007ffda609aa18 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007ffda609aa68 RCX: 00007fb60f4c32e9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 0000000000000000 R08: 00007ffda609ab40 R09: 00007ffda609ab40
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffda609aa60
R13: 00007ffda609ab40 R14: 431bde82d7b634db R15: 00007ffda609aa40
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001c1a9c0 refcount:1 mapcount:1 mapping:0000000000000000 index:0x55be18401 pfn:0x706a7
memcg:ffff88813ff58000
anon flags: 0xfff800000a0014(uptodate|lru|mappedtodisk|swapbacked|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff800000a0014 ffffea000048b888 ffffea0001e6a648 ffff888028074dd1
raw: 000000055be18401 0000000000000000 0000000100000000 ffff88813ff58000
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 3537, tgid 3537 (udevd), ts 84425568408, free_ts 15349359611
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2533
 prep_new_page mm/page_alloc.c:2540 [inline]
 get_page_from_freelist+0x32ed/0x3480 mm/page_alloc.c:4292
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
 __folio_alloc+0xf/0x30 mm/page_alloc.c:5591
 vma_alloc_folio+0x486/0x990 mm/mempolicy.c:2239
 alloc_page_vma include/linux/gfp.h:284 [inline]
 wp_page_copy+0x289/0x1740 mm/memory.c:3114
 handle_pte_fault mm/memory.c:4982 [inline]
 __handle_mm_fault mm/memory.c:5106 [inline]
 handle_mm_fault+0x2522/0x5330 mm/memory.c:5227
 do_user_addr_fault arch/x86/mm/fault.c:1428 [inline]
 handle_page_fault arch/x86/mm/fault.c:1519 [inline]
 exc_page_fault+0x58d/0x790 arch/x86/mm/fault.c:1575
 asm_exc_page_fault+0x22/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:1460 [inline]
 free_pcp_prepare mm/page_alloc.c:1510 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3388
 free_unref_page+0x98/0x570 mm/page_alloc.c:3484
 free_contig_range+0x9a/0x150 mm/page_alloc.c:9519
 destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x416/0x46b mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x265/0x8f0 init/main.c:1303
 do_initcall_level+0x157/0x207 init/main.c:1376
 do_initcalls+0x49/0x86 init/main.c:1392
 kernel_init_freeable+0x473/0x61f init/main.c:1631
 kernel_init+0x19/0x290 init/main.c:1519
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff8880706a6f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880706a6f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880706a7000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                   ^
 ffff8880706a7080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880706a7100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/07 23:14 linux-6.1.y ca48fc16c493 90c93c40 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan KASAN: use-after-free Read in reiserfs_readdir_inode
* Struck through repros no longer work on HEAD.