================================================================== BUG: KASAN: use-after-free in ext4_ext_try_to_merge_right+0x424/0x840 fs/ext4/extents.c:1828 Read of size 718752 at addr ffff88804bda5484 by task syz.0.543/7065 CPU: 0 PID: 7065 Comm: syz.0.543 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 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x27b/0x290 mm/kasan/generic.c:189 memmove+0x25/0x60 mm/kasan/shadow.c:54 ext4_ext_try_to_merge_right+0x424/0x840 fs/ext4/extents.c:1828 ext4_ext_try_to_merge+0x8e/0x620 fs/ext4/extents.c:1905 ext4_ext_insert_extent+0x2181/0x4740 fs/ext4/extents.c:2174 ext4_ext_map_blocks+0x1598/0x66d0 fs/ext4/extents.c:4360 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:ffffc90003407a88 EFLAGS: 00050246 RAX: ffffffff8407c001 RBX: 0000000000000040 RCX: 0000000000000040 RDX: 0000000000000040 RSI: ffffc90003407b20 RDI: 000020000004f000 RBP: 0000000000000000 R08: dffffc0000000000 R09: fffff52000680f6c R10: fffff52000680f6c R11: 1ffff92000680f64 R12: 00007fffffffefc0 R13: 000000007ffe3a80 R14: 000020000004f000 R15: ffffc90003407b20 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:0x7f1694d8e929 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:00007f1695b67038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127 RAX: ffffffffffffffda RBX: 00007f1694fb5fa0 RCX: 00007f1694d8e929 RDX: 0000000000000001 RSI: 0000200000000240 RDI: 0000000000000003 RBP: 00007f1694e10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f1694fb5fa0 R15: 00007ffffaa67a88 The buggy address belongs to the physical page: page:ffffea00012f6940 refcount:2 mapcount:0 mapping:ffff888148d3c9f8 index:0x64 pfn:0x4bda5 memcg:ffff8880794b6000 aops:def_blk_aops ino:700000 flags: 0xfff9800000205a(referenced|dirty|lru|workingset|private|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff9800000205a ffffea0001326488 ffffea0001c770c8 ffff888148d3c9f8 raw: 0000000000000064 ffff88807ada3910 00000002ffffffff ffff8880794b6000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Movable, gfp_mask 0x148c48(GFP_NOFS|__GFP_NOFAIL|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 7065, tgid 7064 (syz.0.543), ts 452317982754, free_ts 452304341424 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 __filemap_get_folio+0x697/0xdd0 mm/filemap.c:1993 pagecache_get_page+0x26/0x250 mm/folio-compat.c:110 find_or_create_page include/linux/pagemap.h:646 [inline] grow_dev_page fs/buffer.c:946 [inline] grow_buffers fs/buffer.c:1011 [inline] __getblk_slow fs/buffer.c:1038 [inline] __getblk_gfp+0x2d8/0xb20 fs/buffer.c:1333 sb_getblk_gfp include/linux/buffer_head.h:363 [inline] ext4_ext_grow_indepth fs/ext4/extents.c:1336 [inline] ext4_ext_create_new_leaf fs/ext4/extents.c:1437 [inline] ext4_ext_insert_extent+0x10e2/0x4740 fs/ext4/extents.c:2105 ext4_ext_map_blocks+0x1598/0x66d0 fs/ext4/extents.c:4360 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 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 truncate_inode_pages mm/truncate.c:451 [inline] truncate_pagecache+0x68/0x80 mm/truncate.c:751 ext4_collapse_range fs/ext4/extents.c:5407 [inline] ext4_fallocate+0xf2b/0x1ff0 fs/ext4/extents.c:4765 vfs_fallocate+0x584/0x6f0 fs/open.c:323 ksys_fallocate fs/open.c:346 [inline] __do_sys_fallocate fs/open.c:354 [inline] __se_sys_fallocate fs/open.c:352 [inline] __x64_sys_fallocate+0xbd/0x100 fs/open.c:352 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 Memory state around the buggy address: ffff88804bdaff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804bdaff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff88804bdb0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff88804bdb0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88804bdb0100: 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