================================================================== BUG: KASAN: use-after-free in leaf_paste_entries+0x64b/0x13a0 fs/reiserfs/lbalance.c:1362 Read of size 2 at addr ffff88804f2ea008 by task syz.2.650/6669 CPU: 0 PID: 6669 Comm: syz.2.650 Not tainted 6.1.106-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15f/0x4f0 mm/kasan/report.c:395 kasan_report+0x136/0x160 mm/kasan/report.c:495 leaf_paste_entries+0x64b/0x13a0 fs/reiserfs/lbalance.c:1362 leaf_copy_dir_entries+0x7ec/0xc60 fs/reiserfs/lbalance.c:119 leaf_copy_boundary_item+0xbbe/0x21b0 fs/reiserfs/lbalance.c:168 leaf_copy_items fs/reiserfs/lbalance.c:551 [inline] leaf_move_items+0xcd0/0x28a0 fs/reiserfs/lbalance.c:726 leaf_shift_left+0xba/0x430 fs/reiserfs/lbalance.c:750 balance_leaf_when_delete_left fs/reiserfs/do_balan.c:194 [inline] balance_leaf_when_delete fs/reiserfs/do_balan.c:272 [inline] balance_leaf+0x228e/0x12510 fs/reiserfs/do_balan.c:1393 do_balance+0x309/0x8f0 fs/reiserfs/do_balan.c:1888 reiserfs_cut_from_item+0x1945/0x2580 fs/reiserfs/stree.c:1838 reiserfs_do_truncate+0xa12/0x15b0 fs/reiserfs/stree.c:1973 reiserfs_truncate_file+0x4d6/0x810 fs/reiserfs/inode.c:2310 reiserfs_setattr+0xc57/0x11c0 fs/reiserfs/inode.c:3395 notify_change+0xce3/0xfc0 fs/attr.c:499 do_truncate+0x21c/0x300 fs/open.c:65 handle_truncate fs/namei.c:3287 [inline] do_open fs/namei.c:3632 [inline] path_openat+0x27e2/0x2e60 fs/namei.c:3785 do_filp_open+0x230/0x480 fs/namei.c:3812 do_sys_openat2+0x13b/0x4f0 fs/open.c:1318 do_sys_open fs/open.c:1334 [inline] __do_sys_openat fs/open.c:1350 [inline] __se_sys_openat fs/open.c:1345 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1345 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7fb6fed79e79 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:00007fb6ffc4d038 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007fb6fef15f80 RCX: 00007fb6fed79e79 RDX: 000000000000275a RSI: 0000000020000040 RDI: ffffffffffffff9c RBP: 00007fb6fede793e R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fb6fef15f80 R15: 00007ffd4f6798f8 The buggy address belongs to the physical page: page:ffffea00013cba80 refcount:1 mapcount:0 mapping:ffff88805c996868 index:0x2b4 pfn:0x4f2ea memcg:ffff88807c976000 aops:shmem_aops ino:100 dentry name:"memfd:syzkaller" flags: 0xfff6000008001e(referenced|uptodate|dirty|lru|swapbacked|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff6000008001e ffffea00015ba348 ffffea00015877c8 ffff88805c996868 raw: 00000000000002b4 0000000000000000 00000001ffffffff ffff88807c976000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Movable, gfp_mask 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 6684, tgid 6683 (syz.3.649), ts 405327941327, free_ts 404516354747 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517 prep_new_page mm/page_alloc.c:2524 [inline] get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4290 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558 __folio_alloc+0xf/0x30 mm/page_alloc.c:5590 vma_alloc_folio+0x486/0x990 mm/mempolicy.c:2243 shmem_alloc_folio mm/shmem.c:1589 [inline] shmem_alloc_and_acct_folio+0x5a8/0xd50 mm/shmem.c:1613 shmem_get_folio_gfp+0x13f0/0x3470 mm/shmem.c:1941 shmem_get_folio mm/shmem.c:2072 [inline] shmem_write_begin+0x16e/0x4e0 mm/shmem.c:2559 generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3817 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3945 generic_file_write_iter+0xab/0x310 mm/filemap.c:3977 call_write_iter include/linux/fs.h:2265 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x857/0xbc0 fs/read_write.c:584 ksys_write+0x19c/0x2c0 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1444 [inline] free_pcp_prepare mm/page_alloc.c:1494 [inline] free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369 free_unref_page_list+0x663/0x900 mm/page_alloc.c:3510 release_pages+0x2836/0x2b40 mm/swap.c:1055 __pagevec_release+0x80/0xf0 mm/swap.c:1075 pagevec_release include/linux/pagevec.h:71 [inline] folio_batch_release include/linux/pagevec.h:135 [inline] shmem_undo_range+0x865/0x2390 mm/shmem.c:946 shmem_truncate_range mm/shmem.c:1062 [inline] shmem_evict_inode+0x265/0xa60 mm/shmem.c:1171 evict+0x2a4/0x620 fs/inode.c:666 __dentry_kill+0x436/0x650 fs/dcache.c:611 dentry_kill+0xbb/0x290 dput+0xfb/0x1d0 fs/dcache.c:918 __fput+0x62e/0x8d0 fs/file_table.c:328 task_work_run+0x246/0x300 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87 Memory state around the buggy address: ffff88804f2e9f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88804f2e9f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88804f2ea000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ ffff88804f2ea080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88804f2ea100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================