syzbot


KASAN: use-after-free Read in sysv_new_block

Status: upstream: reported C repro on 2024/10/20 05:31
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+bc2a78caad1e0b7874c4@syzkaller.appspotmail.com
First crash: 2d15h, last: 2d14h
Bug presence (1)
Date Name Commit Repro Result
2024/10/20 upstream (ToT) 715ca9dd687f C [report] KASAN: slab-out-of-bounds Read in sysv_new_inode
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in sysv_new_block sysv C error 4 663d 692d 0/1 upstream: reported C repro on 2022/11/30 03:11
upstream KASAN: use-after-free Read in sysv_new_block fs C error done 56 1d08h 691d 0/28 upstream: reported C repro on 2022/12/01 12:49
linux-4.14 KASAN: use-after-free Read in sysv_new_block C 1 600d 684d 0/1 upstream: reported C repro on 2022/12/08 01:50

Sample crash report:
unable to read i-node block
==================================================================
BUG: KASAN: use-after-free in sysv_new_block+0x788/0x960 fs/sysv/balloc.c:113
Read of size 4 at addr ffff888065def0c8 by task syz-executor296/3587

CPU: 0 PID: 3587 Comm: syz-executor296 Not tainted 5.15.168-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 sysv_new_block+0x788/0x960 fs/sysv/balloc.c:113
 alloc_branch fs/sysv/itree.c:134 [inline]
 get_block+0x2e7/0x1790 fs/sysv/itree.c:253
 __block_write_begin_int+0x60b/0x1650 fs/buffer.c:2012
 __block_write_begin fs/buffer.c:2062 [inline]
 block_write_begin+0x4f/0xc0 fs/buffer.c:2122
 sysv_write_begin+0x36/0x70 fs/sysv/itree.c:487
 __page_symlink+0x15b/0x2a0 fs/namei.c:5177
 sysv_symlink+0xcb/0x180 fs/sysv/namei.c:86
 vfs_symlink+0x247/0x3d0 fs/namei.c:4429
 do_symlinkat+0x1fd/0x600 fs/namei.c:4458
 __do_sys_symlink fs/namei.c:4480 [inline]
 __se_sys_symlink fs/namei.c:4478 [inline]
 __x64_sys_symlink+0x7a/0x90 fs/namei.c:4478
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f2ab20089e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 1f 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2ab1fba228 EFLAGS: 00000246 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 00007f2ab2099468 RCX: 00007f2ab20089e9
RDX: 00007f2ab20089e9 RSI: 00000000200059c0 RDI: 00000000200049c0
RBP: 00007f2ab2099460 R08: 00007f2ab1fba6c0 R09: 00007f2ab1fba6c0
R10: 00007f2ab1fba6c0 R11: 0000000000000246 R12: 00007f2ab209946c
R13: 0030656c69662f2e R14: 00007f2ab2055340 R15: 00007ffeec4f1de8
 </TASK>

The buggy address belongs to the page:
page:ffffea0001977bc0 refcount:1 mapcount:1 mapping:0000000000000000 index:0x7fffffffb pfn:0x65def
memcg:ffff888017284000
anon flags: 0xfff00000080014(uptodate|lru|swapbacked|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000080014 ffffea0001977b88 ffffea0001977c08 ffff88807d42a441
raw: 00000007fffffffb 0000000000000000 0000000100000000 ffff888017284000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x1100cca(GFP_HIGHUSER_MOVABLE), pid 3029, ts 46767703584, free_ts 10434344804
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 alloc_pages_vma+0x39a/0x800 mm/mempolicy.c:2146
 wp_page_copy+0x24e/0x2070 mm/memory.c:3043
 handle_pte_fault mm/memory.c:4655 [inline]
 __handle_mm_fault mm/memory.c:4772 [inline]
 handle_mm_fault+0x2a3d/0x5960 mm/memory.c:4870
 do_user_addr_fault arch/x86/mm/fault.c:1357 [inline]
 handle_page_fault arch/x86/mm/fault.c:1445 [inline]
 exc_page_fault+0x271/0x700 arch/x86/mm/fault.c:1501
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:606
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_contig_range+0x95/0xf0 mm/page_alloc.c:9342
 destroy_args+0xfe/0x980 mm/debug_vm_pgtable.c:1018
 debug_vm_pgtable+0x40d/0x470 mm/debug_vm_pgtable.c:1331
 do_one_initcall+0x22b/0x7a0 init/main.c:1302
 do_initcall_level+0x157/0x210 init/main.c:1375
 do_initcalls+0x49/0x90 init/main.c:1391
 kernel_init_freeable+0x425/0x5c0 init/main.c:1615
 kernel_init+0x19/0x290 init/main.c:1506
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
 ffff888065deef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888065def000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888065def080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                              ^
 ffff888065def100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888065def180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/20 05:57 linux-5.15.y 584a40a22cb9 cd6fc0a3 .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan KASAN: use-after-free Read in sysv_new_block
2024/10/20 06:07 linux-5.15.y 584a40a22cb9 cd6fc0a3 .config console log report syz / log [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan KASAN: use-after-free Read in sysv_new_block
2024/10/20 05:31 linux-5.15.y 584a40a22cb9 cd6fc0a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in sysv_new_block
* Struck through repros no longer work on HEAD.