================================================================== BUG: KASAN: use-after-free in ext4_ext_binsearch fs/ext4/extents.c:837 [inline] BUG: KASAN: use-after-free in ext4_find_extent+0xbcc/0xe00 fs/ext4/extents.c:953 Read of size 4 at addr ffff88804f401018 by task syz.0.84/4712 CPU: 0 PID: 4712 Comm: syz.0.84 Not tainted 6.1.141-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0xa8/0x220 mm/kasan/report.c:427 kasan_report+0x10b/0x140 mm/kasan/report.c:531 ext4_ext_binsearch fs/ext4/extents.c:837 [inline] ext4_find_extent+0xbcc/0xe00 fs/ext4/extents.c:953 ext4_ext_map_blocks+0x27d/0x66d0 fs/ext4/extents.c:4165 ext4_map_blocks+0x9d1/0x1b60 fs/ext4/inode.c:679 _ext4_get_block+0x1d7/0x4e0 fs/ext4/inode.c:822 ext4_get_block_unwritten+0x2a/0x100 fs/ext4/inode.c:855 __block_write_begin_int+0x54b/0x1a70 fs/buffer.c:1991 __block_write_begin fs/buffer.c:2041 [inline] block_page_mkwrite+0x2d8/0x5f0 fs/buffer.c:2510 ext4_page_mkwrite+0x3b2/0x10c0 fs/ext4/inode.c:6313 do_page_mkwrite+0x16b/0x5c0 mm/memory.c:3011 wp_page_shared+0x167/0x370 mm/memory.c:3360 handle_pte_fault mm/memory.c:5049 [inline] __handle_mm_fault mm/memory.c:5173 [inline] handle_mm_fault+0x1ca6/0x3e70 mm/memory.c:5294 do_user_addr_fault+0x51f/0xb10 arch/x86/mm/fault.c:1340 handle_page_fault arch/x86/mm/fault.c:1431 [inline] exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1487 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608 RIP: 0010:copy_user_enhanced_fast_string+0xa/0x40 arch/x86/lib/copy_user_64.S:166 Code: ff c9 75 f2 89 d1 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 31 c0 0f 01 ca c3 8d 0c ca 89 ca eb 20 0f 01 cb 83 fa 40 72 38 89 d1 a4 31 c0 0f 01 ca c3 89 ca eb 0a 90 90 90 90 90 90 90 90 90 90 RSP: 0018:ffffc900057cfa88 EFLAGS: 00050246 RAX: ffffffff8407c001 RBX: 0000000000000040 RCX: 0000000000000040 RDX: 0000000000000040 RSI: ffffc900057cfb20 RDI: 0000200000053000 RBP: 0000000000000000 R08: dffffc0000000000 R09: fffff52000af9f6c R10: fffff52000af9f6c R11: 1ffff92000af9f64 R12: 00007fffffffefc0 R13: 000000007ffdfa80 R14: 0000200000053000 R15: ffffc900057cfb20 copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline] raw_copy_to_user arch/x86/include/asm/uaccess_64.h:58 [inline] _copy_to_user+0xea/0x130 lib/usercopy.c:41 copy_to_user include/linux/uaccess.h:169 [inline] rng_dev_read+0x3c5/0x710 drivers/char/hw_random/core.c:267 do_loop_readv_writev fs/read_write.c:-1 [inline] do_iter_read+0x49f/0xb10 fs/read_write.c:798 vfs_readv fs/read_write.c:916 [inline] do_preadv+0x1f6/0x330 fs/read_write.c:1008 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7f3547f8e929 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:00007f3548ede038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127 RAX: ffffffffffffffda RBX: 00007f35481b5fa0 RCX: 00007f3547f8e929 RDX: 0000000000000001 RSI: 0000200000000240 RDI: 0000000000000003 RBP: 00007f3548010b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f35481b5fa0 R15: 00007ffd140bf638 The buggy address belongs to the physical page: page:ffffea00013d0040 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x4f401 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 dead000000000100 dead000000000122 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 4509, tgid 4507 (syz.3.39), ts 105780894466, free_ts 107744534344 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2532 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x1a26/0x1ac0 mm/page_alloc.c:4328 __alloc_pages+0x1df/0x4e0 mm/page_alloc.c:5614 __folio_alloc+0xe/0x30 mm/page_alloc.c:5646 vma_alloc_folio+0x4a3/0x900 mm/mempolicy.c:2243 alloc_page_vma include/linux/gfp.h:284 [inline] do_anonymous_page mm/memory.c:4191 [inline] handle_pte_fault mm/memory.c:5029 [inline] __handle_mm_fault mm/memory.c:5173 [inline] handle_mm_fault+0x2242/0x3e70 mm/memory.c:5294 faultin_page mm/gup.c:1026 [inline] __get_user_pages+0x3ff/0xeb0 mm/gup.c:1250 populate_vma_page_range+0x214/0x2b0 mm/gup.c:1607 __mm_populate+0x248/0x370 mm/gup.c:1721 mm_populate include/linux/mm.h:2823 [inline] __do_sys_mremap mm/mremap.c:1100 [inline] __se_sys_mremap+0x7e9/0x10f0 mm/mremap.c:889 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1459 [inline] free_pcp_prepare mm/page_alloc.c:1509 [inline] free_unref_page_prepare+0x8b4/0x9a0 mm/page_alloc.c:3384 free_unref_page_list+0xbb/0x8e0 mm/page_alloc.c:3525 release_pages+0x1f92/0x2200 mm/swap.c:1035 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline] tlb_flush_mmu_free mm/mmu_gather.c:254 [inline] tlb_flush_mmu+0xff/0x210 mm/mmu_gather.c:261 zap_pte_range mm/memory.c:1525 [inline] zap_pmd_range mm/memory.c:1574 [inline] zap_pud_range mm/memory.c:1603 [inline] zap_p4d_range mm/memory.c:1624 [inline] unmap_page_range+0x1f4a/0x2500 mm/memory.c:1645 unmap_vmas+0x22c/0x330 mm/memory.c:1730 exit_mmap+0x1cc/0x8e0 mm/mmap.c:3238 __mmput+0x118/0x3c0 kernel/fork.c:1200 exit_mm+0x1e6/0x2c0 kernel/exit.c:565 do_exit+0x8b9/0x2400 kernel/exit.c:858 do_group_exit+0x217/0x2d0 kernel/exit.c:1021 get_signal+0x1272/0x1350 kernel/signal.c:2871 arch_do_signal_or_restart+0xb0/0x1230 arch/x86/kernel/signal.c:871 exit_to_user_mode_loop+0x70/0x110 kernel/entry/common.c:174 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210 irqentry_exit_to_user_mode+0x5/0x30 kernel/entry/common.c:316 Memory state around the buggy address: ffff88804f400f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804f400f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff88804f401000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff88804f401080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804f401100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== ---------------- Code disassembly (best guess): 0: ff c9 dec %ecx 2: 75 f2 jne 0xfffffff6 4: 89 d1 mov %edx,%ecx 6: c1 e9 03 shr $0x3,%ecx 9: 83 e2 07 and $0x7,%edx c: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi) f: 89 d1 mov %edx,%ecx 11: f3 a4 rep movsb %ds:(%rsi),%es:(%rdi) 13: 31 c0 xor %eax,%eax 15: 0f 01 ca clac 18: c3 ret 19: 8d 0c ca lea (%rdx,%rcx,8),%ecx 1c: 89 ca mov %ecx,%edx 1e: eb 20 jmp 0x40 20: 0f 01 cb stac 23: 83 fa 40 cmp $0x40,%edx 26: 72 38 jb 0x60 28: 89 d1 mov %edx,%ecx * 2a: f3 a4 rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction 2c: 31 c0 xor %eax,%eax 2e: 0f 01 ca clac 31: c3 ret 32: 89 ca mov %ecx,%edx 34: eb 0a jmp 0x40 36: 90 nop 37: 90 nop 38: 90 nop 39: 90 nop 3a: 90 nop 3b: 90 nop 3c: 90 nop 3d: 90 nop 3e: 90 nop 3f: 90 nop