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

1 view
Skip to first unread message

syzbot

unread,
Jul 19, 2023, 10:49:59 AM7/19/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d54cfc420586 Linux 5.15.120
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=10c514c6a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=f546a5c7ff981a94
dashboard link: https://syzkaller.appspot.com/bug?extid=1df2fc26f298c5e1a1dd
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=10deff3aa80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10c87fb6a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/601dfce79849/disk-d54cfc42.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b8e802138c25/vmlinux-d54cfc42.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9b3b48ff5c05/bzImage-d54cfc42.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/ad438eb333f7/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in ext4_ext_binsearch fs/ext4/extents.c:827 [inline]
BUG: KASAN: use-after-free in ext4_find_extent+0xbc4/0xdd0 fs/ext4/extents.c:946
Read of size 4 at addr ffff888071d98064 by task kworker/u4:3/155

CPU: 1 PID: 155 Comm: kworker/u4:3 Not tainted 5.15.120-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
Workqueue: writeback wb_workfn (flush-7:0)
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb 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
ext4_ext_binsearch fs/ext4/extents.c:827 [inline]
ext4_find_extent+0xbc4/0xdd0 fs/ext4/extents.c:946
ext4_ext_map_blocks+0x2ca/0x7220 fs/ext4/extents.c:4103
ext4_map_blocks+0xaad/0x1e30 fs/ext4/inode.c:645
mpage_map_one_extent fs/ext4/inode.c:2406 [inline]
mpage_map_and_submit_extent fs/ext4/inode.c:2459 [inline]
ext4_writepages+0x160e/0x3d10 fs/ext4/inode.c:2827
do_writepages+0x481/0x730 mm/page-writeback.c:2364
__writeback_single_inode+0x15b/0xe30 fs/fs-writeback.c:1625
writeback_sb_inodes+0xbf0/0x1a50 fs/fs-writeback.c:1908
wb_writeback+0x451/0xc50 fs/fs-writeback.c:2082
wb_do_writeback fs/fs-writeback.c:2225 [inline]
wb_workfn+0x46c/0x1130 fs/fs-writeback.c:2266
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2307
worker_thread+0xaca/0x1280 kernel/workqueue.c:2454
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>

The buggy address belongs to the page:
page:ffffea0001c76600 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x71d98
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001c76648 ffffea0001c765c8 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 0x1100dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), pid 3414, ts 37148103316, free_ts 37183785526
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:5421
alloc_pages_vma+0x39a/0x800 mm/mempolicy.c:2146
do_anonymous_page mm/memory.c:3808 [inline]
handle_pte_fault mm/memory.c:4619 [inline]
__handle_mm_fault mm/memory.c:4756 [inline]
handle_mm_fault+0x2f49/0x5950 mm/memory.c:4854
do_user_addr_fault arch/x86/mm/fault.c:1397 [inline]
handle_page_fault arch/x86/mm/fault.c:1485 [inline]
exc_page_fault+0x271/0x740 arch/x86/mm/fault.c:1541
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568
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/0x670 mm/mmap.c:3188
__mmput+0x112/0x3b0 kernel/fork.c:1118
exit_mm+0x688/0x7f0 kernel/exit.c:548
do_exit+0x626/0x2480 kernel/exit.c:859
do_group_exit+0x144/0x310 kernel/exit.c:994
__do_sys_exit_group kernel/exit.c:1005 [inline]
__se_sys_exit_group kernel/exit.c:1003 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1003
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+0x61/0xcb

Memory state around the buggy address:
ffff888071d97f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888071d97f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888071d98000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888071d98080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888071d98100: 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 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