[v6.1] KASAN: use-after-free Read in reiserfs_readdir_inode

0 views
Skip to first unread message

syzbot

unread,
May 7, 2023, 7:16:06 PM5/7/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ca48fc16c493 Linux 6.1.27
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=108dbb14280000
kernel config: https://syzkaller.appspot.com/x/.config?x=47d3bbfdb3b1ddd2
dashboard link: https://syzkaller.appspot.com/bug?extid=570b04e6236b9f102b59
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11512590280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d55e4c280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/658765c915fa/disk-ca48fc16.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d69e8a1aff2d/vmlinux-ca48fc16.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0317a9546209/bzImage-ca48fc16.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/b5a75bde7257/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+570b04...@syzkaller.appspotmail.com

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
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages