BUG: KASAN: use-after-free in ext4_ext_binsearch fs/ext4/extents.c:827 [inline] BUG: KASAN: use-after-free in ext4_find_extent+0xba3/0xd80 fs/ext4/extents.c:946 Read of size 4 at addr ffff888123ed0138 by task kworker/u4:5/506 CPU: 0 PID: 506 Comm: kworker/u4:5 Not tainted 5.15.77-syzkaller-00764-g7048384c9872 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Workqueue: ext4-rsv-conversion ext4_end_io_rsv_work Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description+0x87/0x3d0 mm/kasan/report.c:256 __kasan_report mm/kasan/report.c:435 [inline] kasan_report+0x1a6/0x1f0 mm/kasan/report.c:452 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308 ext4_ext_binsearch fs/ext4/extents.c:827 [inline] ext4_find_extent+0xba3/0xd80 fs/ext4/extents.c:946 ext4_ext_map_blocks+0x22d/0x3cb0 fs/ext4/extents.c:4103 ext4_map_blocks+0xacd/0x1e20 fs/ext4/inode.c:640 ext4_convert_unwritten_extents+0x2ed/0x6e0 fs/ext4/extents.c:4818 ext4_convert_unwritten_io_end_vec+0x11d/0x1d0 fs/ext4/extents.c:4857 ext4_end_io_end fs/ext4/page-io.c:186 [inline] ext4_do_flush_completed_IO fs/ext4/page-io.c:259 [inline] ext4_end_io_rsv_work+0x3a0/0x740 fs/ext4/page-io.c:273 process_one_work+0x6db/0xc00 kernel/workqueue.c:2313 worker_thread+0xb3e/0x1340 kernel/workqueue.c:2460 kthread+0x41c/0x500 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 The buggy address belongs to the page: page:ffffea00048fb400 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x123ed0 flags: 0x4000000000000000(zone=1) raw: 4000000000000000 ffffea00048fb448 ffffea00048fb3c8 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 0x100cca(GFP_HIGHUSER_MOVABLE), pid 487, ts 24271530020, free_ts 24593078666 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x1ab/0x1b0 mm/page_alloc.c:2495 prep_new_page mm/page_alloc.c:2501 [inline] get_page_from_freelist+0x38b/0x400 mm/page_alloc.c:4281 __alloc_pages+0x3a8/0x7c0 mm/page_alloc.c:5548 __alloc_pages_node include/linux/gfp.h:591 [inline] alloc_pages_node include/linux/gfp.h:605 [inline] alloc_pages include/linux/gfp.h:618 [inline] shmem_alloc_page mm/shmem.c:1587 [inline] shmem_alloc_and_acct_page+0x4a0/0xa20 mm/shmem.c:1612 shmem_getpage_gfp+0x1487/0x25f0 mm/shmem.c:1907 shmem_getpage mm/shmem.c:152 [inline] shmem_write_begin+0xc8/0x1b0 mm/shmem.c:2477 generic_perform_write+0x2cd/0x5d0 mm/filemap.c:3825 __generic_file_write_iter+0x25b/0x4b0 mm/filemap.c:3952 generic_file_write_iter+0xaf/0x1c0 mm/filemap.c:3984 call_write_iter include/linux/fs.h:2129 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0xc8d/0x1050 fs/read_write.c:594 ksys_write+0x198/0x2c0 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 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x61/0xcb page last free stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] free_pages_prepare mm/page_alloc.c:1364 [inline] free_pcp_prepare+0x448/0x450 mm/page_alloc.c:1435 free_unref_page_prepare mm/page_alloc.c:3433 [inline] free_unref_page_list+0x16a/0xad0 mm/page_alloc.c:3554 release_pages+0xf3e/0xf90 mm/swap.c:1010 __pagevec_release+0x81/0xf0 mm/swap.c:1030 pagevec_release include/linux/pagevec.h:81 [inline] shmem_undo_range+0x64c/0x1c90 mm/shmem.c:965 shmem_truncate_range mm/shmem.c:1064 [inline] shmem_evict_inode+0x228/0xa30 mm/shmem.c:1146 evict+0x2a3/0x630 fs/inode.c:587 iput_final fs/inode.c:1663 [inline] iput+0x61c/0x7d0 fs/inode.c:1689 dentry_unlink_inode+0x349/0x430 fs/dcache.c:376 __dentry_kill+0x3e2/0x5d0 fs/dcache.c:582 dentry_kill+0xc0/0x2a0 dput+0x175/0x320 fs/dcache.c:888 __fput+0x65a/0x910 fs/file_table.c:288 ____fput+0x15/0x20 fs/file_table.c:308 task_work_run+0x147/0x1b0 kernel/task_work.c:164 ptrace_notify+0x29a/0x340 kernel/signal.c:2382 Memory state around the buggy address: ffff888123ed0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888123ed0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff888123ed0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888123ed0180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888123ed0200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ================================================================== EXT4-fs error (device loop3): ext4_map_blocks:720: inode #19: block 9809717938034: comm kworker/u4:5: lblock 42 mapped to illegal pblock 9809717938034 (length 1) EXT4-fs warning (device loop3): ext4_convert_unwritten_extents:4825: inode #19: block 42: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop3) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop3): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop3): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs error (device loop3): ext4_map_blocks:720: inode #19: block 39599598469194: comm kworker/u4:5: lblock 43 mapped to illegal pblock 39599598469194 (length 1) EXT4-fs warning (device loop3): ext4_convert_unwritten_extents:4825: inode #19: block 43: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop3) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop3): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop3): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs error (device loop3): ext4_map_blocks:720: inode #19: block 39599598469195: comm kworker/u4:5: lblock 44 mapped to illegal pblock 39599598469195 (length 1) EXT4-fs warning (device loop3): ext4_convert_unwritten_extents:4825: inode #19: block 44: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop3) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop3): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop3): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop3): ext4_convert_unwritten_extents:4825: inode #19: block 45: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop3): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs error (device loop1): ext4_map_blocks:720: inode #19: block 227: comm kworker/u4:5: lblock 19 mapped to illegal pblock 227 (length 1) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 19: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop1) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop1): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs error (device loop1): ext4_find_extent:929: inode #19: comm kworker/u4:5: pblk 208 bad header/extent: invalid magic - magic b60f, entries 18482, max 49795(0), depth 18433(0) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 20: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop1) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop1): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs error (device loop1): ext4_find_extent:929: inode #19: comm kworker/u4:5: pblk 208 bad header/extent: invalid magic - magic b60f, entries 18482, max 49795(0), depth 18433(0) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 21: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop1) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop1): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 22: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 23: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 24: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 25: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 26: len 1: ext4_ext_map_blocks returned -117 EXT4-fs (loop1): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117) EXT4-fs warning (device loop1): ext4_convert_unwritten_extents:4825: inode #19: block 27: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop4): ext4_map_blocks:720: inode #19: block 231: comm kworker/u4:5: lblock 23 mapped to illegal pblock 231 (length 1) EXT4-fs warning (device loop4): ext4_convert_unwritten_extents:4825: inode #19: block 23: len 1: ext4_ext_map_blocks returned -117 EXT4-fs error (device loop4) in ext4_reserve_inode_write:5783: Out of memory EXT4-fs error (device loop4): ext4_convert_unwritten_extents:4826: inode #19: comm kworker/u4:5: mark_inode_dirty error EXT4-fs (loop4): failed to convert unwritten extents to written extents -- potential data loss! (inode 19, error -117)