syzbot


KASAN: use-after-free Read in leaf_insert_into_buf

Status: auto-obsoleted due to no activity on 2023/04/17 00:48
Subsystems: reiserfs
[Documentation on labels]
Reported-by: syzbot+6404c1a8cc47c5487e38@syzkaller.appspotmail.com
First crash: 488d, last: 488d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in leaf_insert_into_buf (2) reiserfs 4 325d 355d 0/26 auto-obsoleted due to no activity on 2023/10/07 08:10
linux-6.1 KASAN: out-of-bounds Read in leaf_insert_into_buf origin:upstream C 3 31d 259d 0/3 upstream: reported C repro on 2023/09/02 13:42
linux-5.15 KASAN: out-of-bounds Read in leaf_insert_into_buf origin:upstream C 1 25d 272d 0/3 upstream: reported C repro on 2023/08/21 01:29

Sample crash report:
REISERFS (device loop3): Using r5 hash to sort names
REISERFS (device loop3): using 3.5.x disk format
REISERFS (device loop3): Created .reiserfs_priv - reserved for xattr storage.
==================================================================
BUG: KASAN: use-after-free in leaf_insert_into_buf+0x499/0xa20 fs/reiserfs/lbalance.c:942
Read of size 372 at addr ffff888036838e8c by task syz-executor.3/4653

CPU: 1 PID: 4653 Comm: syz-executor.3 Not tainted 6.2.0-rc4-syzkaller #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:306 [inline]
 print_report+0x15e/0x461 mm/kasan/report.c:417
 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x141/0x190 mm/kasan/generic.c:189
 memmove+0x24/0x60 mm/kasan/shadow.c:54
 leaf_insert_into_buf+0x499/0xa20 fs/reiserfs/lbalance.c:942
 leaf_item_bottle fs/reiserfs/lbalance.c:508 [inline]
 leaf_copy_items fs/reiserfs/lbalance.c:617 [inline]
 leaf_move_items+0x2476/0x3ad0 fs/reiserfs/lbalance.c:726
 balance_leaf_new_nodes_paste_whole fs/reiserfs/do_balan.c:1162 [inline]
 balance_leaf_new_nodes_paste fs/reiserfs/do_balan.c:1215 [inline]
 balance_leaf_new_nodes fs/reiserfs/do_balan.c:1246 [inline]
 balance_leaf+0x2955/0xde40 fs/reiserfs/do_balan.c:1450
 do_balance+0x319/0x810 fs/reiserfs/do_balan.c:1888
 reiserfs_paste_into_item+0x767/0x8e0 fs/reiserfs/stree.c:2159
 reiserfs_get_block+0x1588/0x4150 fs/reiserfs/inode.c:1069
 __block_write_begin_int+0x3bd/0x14b0 fs/buffer.c:1991
 reiserfs_write_begin+0x36e/0xa60 fs/reiserfs/inode.c:2775
 generic_cont_expand_simple+0x117/0x1f0 fs/buffer.c:2347
 reiserfs_setattr+0x39a/0x1460 fs/reiserfs/inode.c:3305
 notify_change+0xca7/0x1420 fs/attr.c:482
 do_truncate+0x143/0x200 fs/open.c:65
 do_sys_ftruncate+0x51f/0x710 fs/open.c:193
 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:0x7fcc9148c0c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fcc8fffe168 EFLAGS: 00000246 ORIG_RAX: 000000000000004d
RAX: ffffffffffffffda RBX: 00007fcc915abf80 RCX: 00007fcc9148c0c9
RDX: 0000000000000000 RSI: 0000000002007ffb RDI: 0000000000000006
RBP: 00007fcc914e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffdf7e7fd1f R14: 00007fcc8fffe300 R15: 0000000000022000
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0000da0e00 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x36838
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0000d9f848 ffffea0000da0dc8 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Movable, gfp_mask 0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_COMP|__GFP_ZERO), pid 4684, tgid 4683 (syz-executor.0), ts 1267147848121, free_ts 1267355067504
 prep_new_page mm/page_alloc.c:2531 [inline]
 get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283
 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549
 __folio_alloc+0x16/0x40 mm/page_alloc.c:5581
 vma_alloc_folio+0x155/0x870 mm/mempolicy.c:2247
 alloc_page_vma include/linux/gfp.h:284 [inline]
 do_anonymous_page mm/memory.c:4074 [inline]
 handle_pte_fault mm/memory.c:4929 [inline]
 __handle_mm_fault+0x1822/0x3c90 mm/memory.c:5073
 handle_mm_fault+0x1b6/0x850 mm/memory.c:5219
 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:1446 [inline]
 free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496
 free_unref_page_prepare mm/page_alloc.c:3369 [inline]
 free_unref_page_list+0x176/0xcd0 mm/page_alloc.c:3510
 release_pages+0xcb1/0x1330 mm/swap.c:1076
 tlb_batch_pages_flush+0xa8/0x1a0 mm/mmu_gather.c:97
 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline]
 tlb_flush_mmu mm/mmu_gather.c:299 [inline]
 tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391
 unmap_region+0x22c/0x2b0 mm/mmap.c:2187
 do_mas_align_munmap+0xc44/0x1260 mm/mmap.c:2440
 do_mas_munmap+0x26e/0x2c0 mm/mmap.c:2498
 __vm_munmap+0x14f/0x290 mm/mmap.c:2775
 __do_sys_munmap mm/mmap.c:2800 [inline]
 __se_sys_munmap mm/mmap.c:2797 [inline]
 __x64_sys_munmap+0x59/0x80 mm/mmap.c:2797
 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

Memory state around the buggy address:
 ffff888036838d80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888036838e00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888036838e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                      ^
 ffff888036838f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888036838f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/17 00:47 upstream 5dc4c995db9e a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in leaf_insert_into_buf
* Struck through repros no longer work on HEAD.