================================================================== BUG: KASAN: use-after-free in ext4_ext_insert_extent+0x2a72/0x4c30 fs/ext4/extents.c:2152 Read of size 137268 at addr ffff88812fa92c3c by task syz.0.16/571 CPU: 1 PID: 571 Comm: syz.0.16 Not tainted 5.10.234-syzkaller-1006684-g094fc3778d6b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x81/0x3b0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:435 [inline] kasan_report+0x179/0x1c0 mm/kasan/report.c:452 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189 memmove+0x2d/0x70 mm/kasan/shadow.c:54 ext4_ext_insert_extent+0x2a72/0x4c30 fs/ext4/extents.c:2152 ext4_ext_map_blocks+0x1c47/0x6ee0 fs/ext4/extents.c:4354 ext4_map_blocks+0xa65/0x1d10 fs/ext4/inode.c:673 _ext4_get_block+0x21b/0x610 fs/ext4/inode.c:816 ext4_get_block+0x39/0x50 fs/ext4/inode.c:833 ext4_block_write_begin+0x61e/0x13b0 fs/ext4/inode.c:1100 ext4_write_begin+0x6fa/0x1730 fs/ext4/ext4_jbd2.h:-1 ext4_da_write_begin+0x49d/0xf60 fs/ext4/inode.c:3032 generic_perform_write+0x2cd/0x570 mm/filemap.c:3509 ext4_buffered_write_iter+0x482/0x610 fs/ext4/file.c:271 ext4_file_write_iter+0x193/0x1c80 fs/ext4/file.c:685 call_write_iter include/linux/fs.h:2058 [inline] new_sync_write fs/read_write.c:518 [inline] vfs_write+0xb4c/0xe70 fs/read_write.c:605 ksys_write+0x199/0x2c0 fs/read_write.c:658 __do_sys_write fs/read_write.c:670 [inline] __se_sys_write fs/read_write.c:667 [inline] __x64_sys_write+0x7b/0x90 fs/read_write.c:667 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:-1 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7fa9fa4a9169 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:00007fa9f9efa038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007fa9fa6c2080 RCX: 00007fa9fa4a9169 RDX: 0000000000040010 RSI: 0000400000000180 RDI: 0000000000000006 RBP: 00007fa9fa52a2a0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fa9fa6c2080 R15: 00007fff0f56d808 The buggy address belongs to the page: page:ffffea0004bea480 refcount:2 mapcount:0 mapping:ffff888100448f50 index:0x3f pfn:0x12fa92 aops:def_blk_aops ino:0 flags: 0x4000000000002014(uptodate|lru|private) raw: 4000000000002014 ffff888115079020 ffffea0004890cc8 ffff888100448f50 raw: 000000000000003f ffff88812e5852a0 00000002ffffffff ffff8881150b4000 page dumped because: kasan: bad access detected page->mem_cgroup:ffff8881150b4000 page_owner tracks the page as allocated page last allocated via order 0, migratetype Movable, gfp_mask 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 571, ts 57786978118, free_ts 57674972983 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2456 [inline] prep_new_page+0x166/0x180 mm/page_alloc.c:2462 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5348 __alloc_pages include/linux/gfp.h:544 [inline] __alloc_pages_node include/linux/gfp.h:557 [inline] alloc_pages_node include/linux/gfp.h:571 [inline] alloc_pages include/linux/gfp.h:590 [inline] __page_cache_alloc include/linux/pagemap.h:290 [inline] pagecache_get_page+0x669/0x950 mm/filemap.c:1848 find_or_create_page include/linux/pagemap.h:402 [inline] grow_dev_page fs/buffer.c:976 [inline] grow_buffers fs/buffer.c:1045 [inline] __getblk_slow fs/buffer.c:1072 [inline] __getblk_gfp+0x221/0x7e0 fs/buffer.c:1370 sb_getblk_gfp include/linux/buffer_head.h:368 [inline] ext4_ext_grow_indepth fs/ext4/extents.c:1327 [inline] ext4_ext_create_new_leaf fs/ext4/extents.c:1426 [inline] ext4_ext_insert_extent+0xf33/0x4c30 fs/ext4/extents.c:2097 ext4_ext_map_blocks+0x1c47/0x6ee0 fs/ext4/extents.c:4354 ext4_map_blocks+0xa65/0x1d10 fs/ext4/inode.c:673 _ext4_get_block+0x21b/0x610 fs/ext4/inode.c:816 ext4_get_block+0x39/0x50 fs/ext4/inode.c:833 ext4_block_write_begin+0x61e/0x13b0 fs/ext4/inode.c:1100 ext4_write_begin+0x6fa/0x1730 fs/ext4/ext4_jbd2.h:-1 ext4_da_write_begin+0x49d/0xf60 fs/ext4/inode.c:3032 generic_perform_write+0x2cd/0x570 mm/filemap.c:3509 ext4_buffered_write_iter+0x482/0x610 fs/ext4/file.c:271 ext4_file_write_iter+0x193/0x1c80 fs/ext4/file.c:685 page last free stack trace: reset_page_owner include/linux/page_owner.h:28 [inline] free_pages_prepare mm/page_alloc.c:1349 [inline] free_pcp_prepare mm/page_alloc.c:1421 [inline] free_unref_page_prepare+0x2ae/0x2d0 mm/page_alloc.c:3336 free_unref_page_list+0x122/0xb20 mm/page_alloc.c:3443 release_pages+0xea0/0xef0 mm/swap.c:1103 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:356 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:326 exit_mmap+0x306/0x560 mm/mmap.c:3375 __mmput+0x95/0x2d0 kernel/fork.c:1153 mmput+0x59/0x170 kernel/fork.c:1176 exit_mm kernel/exit.c:539 [inline] do_exit+0xbda/0x2a50 kernel/exit.c:850 do_group_exit+0x141/0x310 kernel/exit.c:985 get_signal+0x10a0/0x1410 kernel/signal.c:2793 arch_do_signal_or_restart+0xbd/0x17c0 arch/x86/kernel/signal.c:805 handle_signal_work kernel/entry/common.c:145 [inline] exit_to_user_mode_loop+0x9b/0xd0 kernel/entry/common.c:169 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline] syscall_exit_to_user_mode+0xa2/0x1a0 kernel/entry/common.c:274 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x61/0xcb Memory state around the buggy address: ffff88812fa95f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88812fa95f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88812fa96000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff88812fa96080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88812fa96100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== EXT4-fs error (device loop0): ext4_map_blocks:739: inode #17: block 1611822555: comm syz.0.16: lblock 114 mapped to illegal pblock 1611822555 (length 1) EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 213133149369211, count = 22420 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 100016633172565, count = 18370 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 193224731288432, count = 13530 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 199687360352386, count = 4033 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 267324755809180, count = 15703 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 165374944065451, count = 24165 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 274801682251430, count = 17031 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 100084065169146, count = 18061 EXT4-fs error (device loop0): ext4_free_blocks:5685: comm syz.0.16: Freeing blocks not in datazone - block = 251224000247021, count = 3478