================================================================== BUG: KASAN: use-after-free in ext4_ext_rm_leaf fs/ext4/extents.c:2599 [inline] BUG: KASAN: use-after-free in ext4_ext_remove_space+0x3536/0x4180 fs/ext4/extents.c:2937 Read of size 4 at addr ffff8881326a357c by task syz.4.20/562 CPU: 1 PID: 562 Comm: syz.4.20 Not tainted 5.15.185-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: __dump_stack+0x21/0x30 lib/dump_stack.c:88 dump_stack_lvl+0xee/0x150 lib/dump_stack.c:106 print_address_description+0x7f/0x2b0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:434 [inline] kasan_report+0xe0/0x130 mm/kasan/report.c:451 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308 ext4_ext_rm_leaf fs/ext4/extents.c:2599 [inline] ext4_ext_remove_space+0x3536/0x4180 fs/ext4/extents.c:2937 ext4_ext_truncate+0x1a3/0x250 fs/ext4/extents.c:4471 ext4_truncate+0x9a6/0xfa0 fs/ext4/inode.c:4250 ext4_truncate_failed_write fs/ext4/truncate.h:22 [inline] ext4_write_begin+0xa8f/0xfe0 fs/ext4/inode.c:1265 ext4_da_write_begin+0x410/0x8f0 fs/ext4/inode.c:2975 generic_perform_write+0x2a7/0x510 mm/filemap.c:3785 ext4_buffered_write_iter+0x4ed/0x670 fs/ext4/file.c:268 ext4_file_write_iter+0x458/0x14f0 include/linux/fs.h:-1 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0x7b4/0xec0 fs/read_write.c:594 ksys_write+0x140/0x240 fs/read_write.c:647 __do_sys_write fs/read_write.c:659 [inline] __se_sys_write fs/read_write.c:656 [inline] __x64_sys_write+0x7b/0x90 fs/read_write.c:656 x64_sys_call+0x8ef/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:2 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 RIP: 0033:0x7f6bc2e2e929 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:00007f6bc287e038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f6bc3056080 RCX: 00007f6bc2e2e929 RDX: 00000000002a979d RSI: 0000200000000000 RDI: 0000000000000004 RBP: 00007f6bc2eb0b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f6bc3056080 R15: 00007fff7700d408 The buggy address belongs to the page: page:ffffea0004c9a8c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x1326a3 flags: 0x4000000000000000(zone=1) raw: 4000000000000000 ffffea0004c9a908 ffffea0004c9a888 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 0x1100dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), pid 551, ts 55313221803, free_ts 55411846863 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x132/0x160 mm/page_alloc.c:2420 prep_new_page mm/page_alloc.c:2426 [inline] get_page_from_freelist+0x2fda/0x30b0 mm/page_alloc.c:4192 __alloc_pages+0x246/0x4f0 mm/page_alloc.c:5474 __alloc_pages_node include/linux/gfp.h:570 [inline] alloc_pages_node include/linux/gfp.h:584 [inline] alloc_pages include/linux/gfp.h:597 [inline] do_anonymous_page mm/memory.c:3838 [inline] handle_pte_fault mm/memory.c:4648 [inline] __handle_mm_fault mm/memory.c:4785 [inline] handle_mm_fault+0x1c3c/0x3520 mm/memory.c:4883 do_user_addr_fault+0x4c2/0xc80 arch/x86/mm/fault.c:1357 handle_page_fault arch/x86/mm/fault.c:1445 [inline] exc_page_fault+0x51/0xb0 arch/x86/mm/fault.c:1501 asm_exc_page_fault+0x27/0x30 arch/x86/include/asm/idtentry.h:606 copy_user_enhanced_fast_string+0xe/0x40 arch/x86/lib/copy_user_64.S:205 copy_to_iter include/linux/uio.h:155 [inline] get_random_bytes_user+0x19d/0x370 drivers/char/random.c:474 __do_sys_getrandom drivers/char/random.c:1242 [inline] __se_sys_getrandom drivers/char/random.c:1215 [inline] __x64_sys_getrandom+0x1be/0x2a0 drivers/char/random.c:1215 x64_sys_call+0x426/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:319 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1340 [inline] free_pcp_prepare mm/page_alloc.c:1413 [inline] free_unref_page_prepare+0x4f6/0x530 mm/page_alloc.c:3317 free_unref_page_list+0x11a/0x690 mm/page_alloc.c:3433 release_pages+0xc71/0xcd0 mm/swap.c:963 free_pages_and_swap_cache+0x86/0xa0 mm/swap_state.c:320 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+0x175/0x300 mm/mmu_gather.c:338 exit_mmap+0x3b6/0x5a0 mm/mmap.c:3206 __mmput+0x93/0x310 kernel/fork.c:1127 mmput+0x4c/0x60 kernel/fork.c:1148 exit_mm kernel/exit.c:550 [inline] do_exit+0x9b0/0x2510 kernel/exit.c:861 do_group_exit+0x141/0x310 kernel/exit.c:996 get_signal+0x65e/0x1470 kernel/signal.c:2900 arch_do_signal_or_restart+0xc1/0x10f0 arch/x86/kernel/signal.c:867 handle_signal_work kernel/entry/common.c:154 [inline] exit_to_user_mode_loop+0xa7/0xe0 kernel/entry/common.c:178 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x1a/0x30 kernel/entry/common.c:307 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86 Memory state around the buggy address: ffff8881326a3400: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8881326a3480: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8881326a3500: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8881326a3580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8881326a3600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 183631372498363, count = 17062 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 119451303899139, count = 5468 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 215532200467161, count = 23715 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 238859253407218, count = 12958 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 75872840937881, count = 9771 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 224486277458689, count = 10951 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 29979553318982, count = 6625 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 31815313067544, count = 21200 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 59725342771558, count = 24237 EXT4-fs error (device loop4): ext4_free_blocks:6223: comm syz.4.20: Freeing blocks not in datazone - block = 222880472508802, count = 13277