================================================================== 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 ffff8880518d0e18 by task syz.2.92/4942 CPU: 0 PID: 4942 Comm: syz.2.92 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 do_shared_fault mm/memory.c:4696 [inline] do_fault mm/memory.c:4764 [inline] handle_pte_fault mm/memory.c:5031 [inline] __handle_mm_fault mm/memory.c:5173 [inline] handle_mm_fault+0x1b10/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:ffffc90003967a88 EFLAGS: 00050246 RAX: ffffffff8407c001 RBX: 0000000000000040 RCX: 0000000000000040 RDX: 0000000000000040 RSI: ffffc90003967b20 RDI: 000020000004f000 RBP: 0000000000000000 R08: dffffc0000000000 R09: fffff5200072cf6c R10: fffff5200072cf6c R11: 1ffff9200072cf64 R12: 00007fffffffefc0 R13: 000000007ffe3a80 R14: 000020000004f000 R15: ffffc90003967b20 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:0x7f8cdfd8e929 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:00007f8ce0c81038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127 RAX: ffffffffffffffda RBX: 00007f8cdffb5fa0 RCX: 00007f8cdfd8e929 RDX: 0000000000000001 RSI: 0000200000000240 RDI: 0000000000000003 RBP: 00007f8cdfe10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f8cdffb5fa0 R15: 00007ffead40bba8 The buggy address belongs to the physical page: page:ffffea0001463400 refcount:0 mapcount:-128 mapping:0000000000000000 index:0x1 pfn:0x518d0 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000000 ffffea00014a8408 ffffea0001530e08 0000000000000000 raw: 0000000000000001 0000000000000002 00000000ffffff7f 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 0x152c4a(GFP_NOFS|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 4904, tgid 4900 (syz.2.88), ts 157525368430, free_ts 158819115686 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+0x1c/0x60 mm/mempolicy.c:2292 filemap_alloc_folio+0xdb/0x460 mm/filemap.c:999 page_cache_ra_unbounded+0x177/0x770 mm/readahead.c:248 do_sync_mmap_readahead+0x5ea/0x780 mm/filemap.c:3136 filemap_fault+0x6d7/0x1670 mm/filemap.c:3228 __do_fault+0x13b/0x4e0 mm/memory.c:4280 do_read_fault mm/memory.c:4631 [inline] do_fault mm/memory.c:4760 [inline] handle_pte_fault mm/memory.c:5031 [inline] __handle_mm_fault mm/memory.c:5173 [inline] handle_mm_fault+0x28ca/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] vm_mmap_pgoff+0x203/0x2b0 mm/util.c:525 ksys_mmap_pgoff+0x516/0x6f0 mm/mmap.c:1470 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81 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 __pagevec_release+0x6d/0xe0 mm/swap.c:1055 pagevec_release include/linux/pagevec.h:71 [inline] folio_batch_release include/linux/pagevec.h:135 [inline] truncate_inode_pages_range+0x2f6/0xff0 mm/truncate.c:372 ext4_evict_inode+0x568/0x1100 fs/ext4/inode.c:210 evict+0x485/0x870 fs/inode.c:705 dispose_list fs/inode.c:738 [inline] evict_inodes+0x604/0x690 fs/inode.c:792 generic_shutdown_super+0x93/0x340 fs/super.c:480 kill_block_super+0x7c/0xe0 fs/super.c:1470 deactivate_locked_super+0x93/0xf0 fs/super.c:332 cleanup_mnt+0x463/0x4f0 fs/namespace.c:1182 task_work_run+0x1ca/0x250 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xe6/0x110 kernel/entry/common.c:177 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:303 Memory state around the buggy address: ffff8880518d0d00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880518d0d80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880518d0e00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880518d0e80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880518d0f00: 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