================================================================== BUG: KASAN: use-after-free in ext4_ext_binsearch_idx fs/ext4/extents.c:768 [inline] BUG: KASAN: use-after-free in ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:931 Read of size 4 at addr ffff888124513828 by task syz-executor.0/385 CPU: 0 PID: 385 Comm: syz-executor.0 Not tainted 6.2.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1c0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x164/0x510 mm/kasan/report.c:417 kasan_report+0x13f/0x170 mm/kasan/report.c:517 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:350 ext4_ext_binsearch_idx fs/ext4/extents.c:768 [inline] ext4_find_extent+0x697/0xd80 fs/ext4/extents.c:931 ext4_clu_mapped+0x116/0x9a0 fs/ext4/extents.c:5809 ext4_insert_delayed_block fs/ext4/inode.c:1696 [inline] ext4_da_map_blocks fs/ext4/inode.c:1806 [inline] ext4_da_get_block_prep+0xa16/0x1410 fs/ext4/inode.c:1870 ext4_block_write_begin+0x5c5/0x1200 fs/ext4/inode.c:1098 ext4_da_write_begin+0x509/0x8d0 fs/ext4/inode.c:3082 generic_perform_write+0x314/0x5f0 mm/filemap.c:3772 ext4_buffered_write_iter+0x35f/0x640 fs/ext4/file.c:285 ext4_file_write_iter+0x198/0x1cc0 call_write_iter include/linux/fs.h:2186 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x8b5/0xef0 fs/read_write.c:584 ksys_write+0x198/0x2c0 fs/read_write.c:637 __do_sys_write fs/read_write.c:649 [inline] __se_sys_write fs/read_write.c:646 [inline] __x64_sys_write+0x7b/0x90 fs/read_write.c:646 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f81cd68c0a9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f81ce3a3168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f81cd7abf80 RCX: 00007f81cd68c0a9 RDX: 00000000175d9003 RSI: 0000000020000200 RDI: 0000000000000004 RBP: 00007f81cd6e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe2f68c3df R14: 00007f81ce3a3300 R15: 0000000000022000 Allocated by task 377: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:507 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:325 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:761 [inline] slab_alloc_node mm/slub.c:3452 [inline] slab_alloc mm/slub.c:3460 [inline] __kmem_cache_alloc_lru mm/slub.c:3467 [inline] kmem_cache_alloc_lru+0x15b/0x340 mm/slub.c:3483 alloc_inode_sb include/linux/fs.h:3116 [inline] sock_alloc_inode+0x25/0xb0 net/socket.c:304 alloc_inode fs/inode.c:259 [inline] new_inode_pseudo+0x65/0x1d0 fs/inode.c:1018 sock_alloc net/socket.c:627 [inline] __sock_create+0x136/0x770 net/socket.c:1479 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket+0x137/0x3a0 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 23: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:518 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:236 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0xc9/0x1a0 mm/slub.c:1807 slab_free mm/slub.c:3787 [inline] kmem_cache_free+0x136/0x2b0 mm/slub.c:3809 sock_free_inode+0x1d/0x20 net/socket.c:325 i_callback+0x4b/0x70 fs/inode.c:248 rcu_do_batch+0x521/0xb70 kernel/rcu/tree.c:2246 rcu_core+0x4dd/0xf00 kernel/rcu/tree.c:2506 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2523 __do_softirq+0x1a5/0x5a3 kernel/softirq.c:571 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:488 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:498 __call_rcu_common kernel/rcu/tree.c:2755 [inline] call_rcu+0xf9/0x14b0 kernel/rcu/tree.c:2868 destroy_inode fs/inode.c:314 [inline] evict+0x5de/0x630 fs/inode.c:679 iput_final fs/inode.c:1747 [inline] iput+0x61e/0x850 fs/inode.c:1773 dentry_unlink_inode+0x349/0x430 fs/dcache.c:401 __dentry_kill+0x3e2/0x5d0 fs/dcache.c:607 dentry_kill+0xc0/0x2a0 dput+0x175/0x320 fs/dcache.c:913 __fput+0x657/0x900 fs/file_table.c:328 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x243/0x2f0 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x8b/0xd0 kernel/entry/common.c:171 exit_to_user_mode_prepare+0x59/0x80 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:296 do_syscall_64+0x3b/0x50 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888124513800 which belongs to the cache sock_inode_cache of size 768 The buggy address is located 40 bytes inside of 768-byte region [ffff888124513800, ffff888124513b00) The buggy address belongs to the physical page: page:ffffea0004914400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x124510 head:ffffea0004914400 order:2 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head|zone=1) raw: 4000000000010200 ffff88810892ab40 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000120012 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Reclaimable, gfp_mask 0x1d20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 377, tgid 377 (syz-executor.0), ts 36791309295, free_ts 19359830505 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1eb/0x1f0 mm/page_alloc.c:2524 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x375/0x3f0 mm/page_alloc.c:4283 __alloc_pages+0x3d1/0x7c0 mm/page_alloc.c:5549 allocate_slab+0xb2/0x410 mm/slub.c:1998 new_slab mm/slub.c:2051 [inline] ___slab_alloc+0x4da/0x940 mm/slub.c:3193 __slab_alloc mm/slub.c:3292 [inline] __slab_alloc_node mm/slub.c:3345 [inline] slab_alloc_node mm/slub.c:3442 [inline] slab_alloc mm/slub.c:3460 [inline] __kmem_cache_alloc_lru mm/slub.c:3467 [inline] kmem_cache_alloc_lru+0x204/0x340 mm/slub.c:3483 alloc_inode_sb include/linux/fs.h:3116 [inline] sock_alloc_inode+0x25/0xb0 net/socket.c:304 alloc_inode fs/inode.c:259 [inline] new_inode_pseudo+0x65/0x1d0 fs/inode.c:1018 sock_alloc net/socket.c:627 [inline] __sock_create+0x136/0x770 net/socket.c:1479 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket+0x137/0x3a0 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] __free_pages_ok+0x867/0x870 mm/page_alloc.c:1702 free_the_page mm/page_alloc.c:752 [inline] free_compound_page+0xb0/0xd0 mm/page_alloc.c:773 free_transhuge_page+0x289/0x2c0 mm/huge_memory.c:2814 destroy_large_folio+0x55/0x80 mm/page_alloc.c:811 __folio_put_large mm/swap.c:119 [inline] release_pages+0x3b8/0xdb0 mm/swap.c:1042 free_pages_and_swap_cache+0x9b/0xb0 mm/swap_state.c:311 tlb_batch_pages_flush mm/mmu_gather.c:97 [inline] tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu+0x800/0xa00 mm/mmu_gather.c:299 tlb_finish_mmu+0xd4/0x1f0 mm/mmu_gather.c:391 exit_mmap+0x2ab/0x6d0 mm/mmap.c:3096 __mmput+0x95/0x300 kernel/fork.c:1207 mmput+0x50/0x60 kernel/fork.c:1229 exit_mm+0x126/0x1e0 kernel/exit.c:563 do_exit+0x8e9/0x2700 kernel/exit.c:854 do_group_exit+0x215/0x2d0 kernel/exit.c:1012 __do_sys_exit_group kernel/exit.c:1023 [inline] __se_sys_exit_group kernel/exit.c:1021 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1021 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80 Memory state around the buggy address: ffff888124513700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888124513780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888124513800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888124513880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888124513900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================