[v5.15] KASAN: use-after-free Read in ocfs2_search_dirblock

1 view
Skip to first unread message

syzbot

unread,
Feb 4, 2025, 5:38:25 AM2/4/25
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c16c81c81336 Linux 5.15.178
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11a94f64580000
kernel config: https://syzkaller.appspot.com/x/.config?x=d302c69e93fb6774
dashboard link: https://syzkaller.appspot.com/bug?extid=d130f28df53499b7caaf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/267e46ee7273/disk-c16c81c8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/944e289206cf/vmlinux-c16c81c8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f8cadf62458e/bzImage-c16c81c8.xz

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

loop0: detected capacity change from 0 to 32768
ocfs2: Mounting device (7,0) on (node local, slot 0) with ordered data mode.
==================================================================
BUG: KASAN: use-after-free in ocfs2_match fs/ocfs2/dir.c:334 [inline]
BUG: KASAN: use-after-free in ocfs2_search_dirblock+0x267/0x7f0 fs/ocfs2/dir.c:367
Read of size 1 at addr ffff88805d87d8cb by task syz.0.120/4691

CPU: 0 PID: 4691 Comm: syz.0.120 Not tainted 5.15.178-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/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
ocfs2_match fs/ocfs2/dir.c:334 [inline]
ocfs2_search_dirblock+0x267/0x7f0 fs/ocfs2/dir.c:367
ocfs2_find_entry_id fs/ocfs2/dir.c:414 [inline]
ocfs2_find_entry+0x114b/0x26d0 fs/ocfs2/dir.c:1078
ocfs2_find_files_on_disk+0xea/0x310 fs/ocfs2/dir.c:1982
ocfs2_lookup_ino_from_name+0xad/0x1e0 fs/ocfs2/dir.c:2004
ocfs2_lookup+0x27b/0x9f0 fs/ocfs2/namei.c:122
lookup_open fs/namei.c:3440 [inline]
open_last_lookups fs/namei.c:3532 [inline]
path_openat+0x111d/0x2f20 fs/namei.c:3739
do_filp_open+0x21c/0x460 fs/namei.c:3769
do_sys_openat2+0x13b/0x4f0 fs/open.c:1253
do_sys_open fs/open.c:1269 [inline]
__do_sys_openat fs/open.c:1285 [inline]
__se_sys_openat fs/open.c:1280 [inline]
__x64_sys_openat+0x243/0x290 fs/open.c:1280
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:0x7f7ba8a51da9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7ba68bb038 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f7ba8c6afa0 RCX: 00007f7ba8a51da9
RDX: 000000000000275a RSI: 00000000200001c0 RDI: ffffffffffffff9c
RBP: 00007f7ba8ad32a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7ba8c6afa0 R15: 00007ffd91d24908
</TASK>

The buggy address belongs to the page:
page:ffffea0001761f40 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x5d87d
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001761ec8 ffffea0001761f88 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 0x1100cca(GFP_HIGHUSER_MOVABLE), pid 4694, ts 108208812673, free_ts 108238281570
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
__alloc_pages+0x272/0x700 mm/page_alloc.c:5465
alloc_pages_vma+0x39a/0x800 mm/mempolicy.c:2146
do_cow_fault mm/memory.c:4281 [inline]
do_fault mm/memory.c:4392 [inline]
handle_pte_fault mm/memory.c:4648 [inline]
__handle_mm_fault mm/memory.c:4783 [inline]
handle_mm_fault+0x2597/0x5960 mm/memory.c:4881
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_list+0x1f7/0x8e0 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:240 [inline]
tlb_flush_mmu mm/mmu_gather.c:247 [inline]
tlb_finish_mmu+0x177/0x320 mm/mmu_gather.c:338
exit_mmap+0x3cd/0x620 mm/mmap.c:3206
__mmput+0x112/0x3b0 kernel/fork.c:1127
exit_mm+0x688/0x7f0 kernel/exit.c:550
do_exit+0x626/0x2480 kernel/exit.c:861
do_group_exit+0x144/0x310 kernel/exit.c:996
__do_sys_exit_group kernel/exit.c:1007 [inline]
__se_sys_exit_group kernel/exit.c:1005 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1005
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

Memory state around the buggy address:
ffff88805d87d780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805d87d800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88805d87d880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88805d87d900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805d87d980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


---
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 report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

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

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

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Feb 4, 2025, 7:43:24 AM2/4/25
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: c16c81c81336 Linux 5.15.178
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1790a3df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=d302c69e93fb6774
dashboard link: https://syzkaller.appspot.com/bug?extid=d130f28df53499b7caaf
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12ddeeb0580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12615d18580000
mounted in repro: https://storage.googleapis.com/syzbot-assets/e72b9413e51c/mount_0.gz

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

loop0: detected capacity change from 0 to 32768
ocfs2: Mounting device (7,0) on (node local, slot 0) with ordered data mode.
==================================================================
BUG: KASAN: use-after-free in ocfs2_match fs/ocfs2/dir.c:334 [inline]
BUG: KASAN: use-after-free in ocfs2_search_dirblock+0x267/0x7f0 fs/ocfs2/dir.c:367
Read of size 1 at addr ffff88806de318cb by task syz-executor292/4172

CPU: 1 PID: 4172 Comm: syz-executor292 Not tainted 5.15.178-syzkaller #0
RIP: 0033:0x7ff9695ca769
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 18 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:00007ffed3ffeb68 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007ff9695ca769
RDX: 000000000000275a RSI: 00000000200001c0 RDI: 00000000ffffff9c
RBP: 0000000000000004 R08: 0000000000004433 R09: 00000000000088c0
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffed3ffebb0
R13: 00007ffed3ffebf0 R14: 0000000001000000 R15: 0000000000000003
</TASK>

The buggy address belongs to the page:
page:ffffea0001b78c40 refcount:0 mapcount:0 mapping:0000000000000000 index:0x100 pfn:0x6de31
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 dead000000000100 dead000000000122 0000000000000000
raw: 0000000000000100 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 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 4169, ts 61157768261, free_ts 61201821346
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
__alloc_pages+0x272/0x700 mm/page_alloc.c:5465
__page_cache_alloc+0xd4/0x4a0 mm/filemap.c:1022
pagecache_get_page+0xa91/0x1010 mm/filemap.c:1940
find_or_create_page include/linux/pagemap.h:420 [inline]
grow_dev_page fs/buffer.c:949 [inline]
grow_buffers fs/buffer.c:1014 [inline]
__getblk_slow fs/buffer.c:1041 [inline]
__getblk_gfp+0x22a/0xaf0 fs/buffer.c:1336
sb_getblk include/linux/buffer_head.h:361 [inline]
ocfs2_read_blocks_sync+0x407/0xbc0 fs/ocfs2/buffer_head_io.c:109
ocfs2_read_locked_inode fs/ocfs2/inode.c:503 [inline]
ocfs2_iget+0x9db/0x1f90 fs/ocfs2/inode.c:159
_ocfs2_get_system_file_inode fs/ocfs2/sysfile.c:142 [inline]
ocfs2_get_system_file_inode+0x353/0x7b0 fs/ocfs2/sysfile.c:112
ocfs2_init_local_system_inodes fs/ocfs2/super.c:488 [inline]
ocfs2_mount_volume+0x2f7/0x19e0 fs/ocfs2/super.c:1816
ocfs2_fill_super+0x34ec/0x5890 fs/ocfs2/super.c:1083
mount_bdev+0x2c9/0x3f0 fs/super.c:1400
legacy_get_tree+0xeb/0x180 fs/fs_context.c:611
vfs_get_tree+0x88/0x270 fs/super.c:1530
do_new_mount+0x2ba/0xb40 fs/namespace.c:3012
do_mount fs/namespace.c:3355 [inline]
__do_sys_mount fs/namespace.c:3563 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3540
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
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_list+0x1f7/0x8e0 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
__pagevec_release+0x80/0xf0 mm/swap.c:983
pagevec_release include/linux/pagevec.h:81 [inline]
truncate_inode_pages_range+0x48b/0x1290 mm/truncate.c:329
kill_bdev block/bdev.c:77 [inline]
blkdev_flush_mapping+0x182/0x340 block/bdev.c:659
blkdev_put_whole block/bdev.c:690 [inline]
blkdev_put+0x4f1/0x790 block/bdev.c:954
deactivate_locked_super+0xa0/0x110 fs/super.c:335
cleanup_mnt+0x44e/0x500 fs/namespace.c:1143
task_work_run+0x129/0x1a0 kernel/task_work.c:188
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
__syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
ffff88806de31780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88806de31800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88806de31880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88806de31900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88806de31980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================


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

syzbot

unread,
Apr 10, 2025, 11:00:06 PM4/10/25
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 03b605ac1e5bf3684cc7a64c0de646aaeb367ff1
Author: Su Yue <glas...@suse.com>
Date: Mon Jan 6 14:06:40 2025 +0000

ocfs2: check dir i_size in ocfs2_find_entry

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12220a3f980000
start commit: c16c81c81336 Linux 5.15.178
git tree: linux-5.15.y
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1367b8a4580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11a3eeb0580000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: ocfs2: check dir i_size in ocfs2_find_entry

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages