================================================================== BUG: KASAN: use-after-free in ext4_ext_binsearch fs/ext4/extents.c:837 [inline] BUG: KASAN: use-after-free in ext4_find_extent+0xbc8/0xde0 fs/ext4/extents.c:953 Read of size 4 at addr ffff8880893a1500 by task syz-executor.2/13151 CPU: 0 PID: 13151 Comm: syz-executor.2 Not tainted 6.5.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0x163/0x540 mm/kasan/report.c:475 kasan_report+0x175/0x1b0 mm/kasan/report.c:588 ext4_ext_binsearch fs/ext4/extents.c:837 [inline] ext4_find_extent+0xbc8/0xde0 fs/ext4/extents.c:953 ext4_ext_map_blocks+0x2d1/0x71d0 fs/ext4/extents.c:4101 ext4_map_blocks+0xa2f/0x1cb0 fs/ext4/inode.c:621 _ext4_get_block+0x238/0x6a0 fs/ext4/inode.c:763 __block_write_begin_int+0x555/0x1a60 fs/buffer.c:2128 block_page_mkwrite+0x29d/0x4e0 fs/buffer.c:2651 ext4_page_mkwrite+0x500/0x1290 fs/ext4/inode.c:6116 do_page_mkwrite+0x1a4/0x600 mm/memory.c:2942 wp_page_shared mm/memory.c:3294 [inline] do_wp_page+0x559/0x3a70 mm/memory.c:3376 handle_pte_fault mm/memory.c:4955 [inline] __handle_mm_fault mm/memory.c:5079 [inline] handle_mm_fault+0x1c58/0x5410 mm/memory.c:5233 do_user_addr_fault arch/x86/mm/fault.c:1392 [inline] handle_page_fault arch/x86/mm/fault.c:1486 [inline] exc_page_fault+0x266/0x7c0 arch/x86/mm/fault.c:1542 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570 RIP: 0010:rep_movs_alternative+0x4a/0xb0 arch/x86/lib/copy_user_64.S:71 Code: 75 f1 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 8b 06 48 89 07 48 83 c6 08 48 83 c7 08 83 e9 08 74 df 83 f9 08 73 e8 eb c9 a4 c3 0f 1f 00 4c 8b 06 4c 8b 4e 08 4c 8b 56 10 4c 8b 5e 18 4c RSP: 0018:ffffc900155ef918 EFLAGS: 00050206 RAX: ffffffff84346701 RBX: 0000000020000a00 RCX: 0000000000000a00 RDX: 0000000000000000 RSI: ffff88808d2d3600 RDI: 0000000020001000 RBP: ffffc900155efa78 R08: ffff88808d2d3fff R09: 1ffff11011a5a7ff R10: dffffc0000000000 R11: ffffed1011a5a800 R12: 1ffff92002abdfb3 R13: ffff88808d2d3000 R14: 0000000000001000 R15: ffffc900155efd98 copy_user_generic arch/x86/include/asm/uaccess_64.h:112 [inline] raw_copy_to_user arch/x86/include/asm/uaccess_64.h:133 [inline] copyout lib/iov_iter.c:168 [inline] _copy_to_iter+0x241/0x1000 lib/iov_iter.c:316 copy_page_to_iter+0xb1/0x160 lib/iov_iter.c:481 copy_folio_to_iter include/linux/uio.h:185 [inline] filemap_read+0x86b/0x10d0 mm/filemap.c:2709 call_read_iter include/linux/fs.h:1865 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x795/0xb00 fs/read_write.c:470 ksys_read+0x1a0/0x2c0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f7b99c7cae9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f7b9a8ee0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00007f7b99d9bf80 RCX: 00007f7b99c7cae9 RDX: 000000000000ffd2 RSI: 0000000020000a00 RDI: 0000000000000006 RBP: 00007f7b99cc847a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007f7b99d9bf80 R15: 00007ffd7ae44a98 The buggy address belongs to the physical page: page:ffffea000224e840 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x893a1 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() 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 6940, tgid 6937 (syz-executor.3), ts 276010488722, free_ts 277064240574 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0x31e8/0x3370 mm/page_alloc.c:3221 __alloc_pages+0x255/0x670 mm/page_alloc.c:4477 __folio_alloc+0x13/0x30 mm/page_alloc.c:4509 vma_alloc_folio+0x48a/0x9a0 mm/mempolicy.c:2253 do_anonymous_page mm/memory.c:4104 [inline] do_pte_missing mm/memory.c:3662 [inline] handle_pte_fault mm/memory.c:4939 [inline] __handle_mm_fault mm/memory.c:5079 [inline] handle_mm_fault+0x20c7/0x5410 mm/memory.c:5233 do_user_addr_fault arch/x86/mm/fault.c:1343 [inline] handle_page_fault arch/x86/mm/fault.c:1486 [inline] exc_page_fault+0x3cf/0x7c0 arch/x86/mm/fault.c:1542 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:1161 [inline] free_unref_page_prepare+0x903/0xa30 mm/page_alloc.c:2348 free_unref_page_list+0x596/0x830 mm/page_alloc.c:2489 release_pages+0x2193/0x2470 mm/swap.c:1042 tlb_batch_pages_flush mm/mmu_gather.c:97 [inline] tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu+0x100/0x210 mm/mmu_gather.c:299 tlb_finish_mmu+0xd4/0x1f0 mm/mmu_gather.c:391 unmap_region+0x258/0x2a0 mm/mmap.c:2318 do_vmi_align_munmap+0x135d/0x1630 mm/mmap.c:2557 do_vmi_munmap+0x24d/0x2d0 mm/mmap.c:2624 __vm_munmap+0x230/0x450 mm/mmap.c:2906 __do_sys_munmap mm/mmap.c:2923 [inline] __se_sys_munmap mm/mmap.c:2920 [inline] __x64_sys_munmap+0x69/0x80 mm/mmap.c:2920 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff8880893a1400: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880893a1480: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880893a1500: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880893a1580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880893a1600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== ---------------- Code disassembly (best guess): 0: 75 f1 jne 0xfffffff3 2: c3 ret 3: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) a: 00 00 00 d: 0f 1f 00 nopl (%rax) 10: 48 8b 06 mov (%rsi),%rax 13: 48 89 07 mov %rax,(%rdi) 16: 48 83 c6 08 add $0x8,%rsi 1a: 48 83 c7 08 add $0x8,%rdi 1e: 83 e9 08 sub $0x8,%ecx 21: 74 df je 0x2 23: 83 f9 08 cmp $0x8,%ecx 26: 73 e8 jae 0x10 28: eb c9 jmp 0xfffffff3 * 2a: f3 a4 rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction 2c: c3 ret 2d: 0f 1f 00 nopl (%rax) 30: 4c 8b 06 mov (%rsi),%r8 33: 4c 8b 4e 08 mov 0x8(%rsi),%r9 37: 4c 8b 56 10 mov 0x10(%rsi),%r10 3b: 4c 8b 5e 18 mov 0x18(%rsi),%r11 3f: 4c rex.WR