EXT4-fs error (device loop0): ext4_xattr_ibody_find:2265: inode #12: comm syz-executor.0: corrupted in-inode xattr: bad magic number in in-inode xattr ================================================================== BUG: KASAN: slab-use-after-free in get_max_inline_xattr_value_size+0x369/0x510 fs/ext4/inline.c:62 Read of size 4 at addr ffff88807d7ae030 by task syz-executor.0/16770 CPU: 1 PID: 16770 Comm: syz-executor.0 Not tainted 6.3.0-rc6-syzkaller-00173-g7a934f4bd7d6 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:319 [inline] print_report+0x163/0x540 mm/kasan/report.c:430 kasan_report+0x176/0x1b0 mm/kasan/report.c:536 get_max_inline_xattr_value_size+0x369/0x510 fs/ext4/inline.c:62 ext4_update_inline_dir fs/ext4/inline.c:1109 [inline] ext4_try_add_inline_entry+0x34b/0xb70 fs/ext4/inline.c:1306 ext4_add_entry+0x535/0x1010 fs/ext4/namei.c:2384 ext4_mkdir+0x553/0xce0 fs/ext4/namei.c:3006 vfs_mkdir+0x29d/0x450 fs/namei.c:4038 do_mkdirat+0x264/0x520 fs/namei.c:4061 __do_sys_mkdir fs/namei.c:4081 [inline] __se_sys_mkdir fs/namei.c:4079 [inline] __x64_sys_mkdir+0x6e/0x80 fs/namei.c:4079 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f7a1e08c169 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:00007f7a1ed2a168 EFLAGS: 00000246 ORIG_RAX: 0000000000000053 RAX: ffffffffffffffda RBX: 00007f7a1e1abf80 RCX: 00007f7a1e08c169 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200000c0 RBP: 00007f7a1e0e7ca1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeb8fb9f1f R14: 00007f7a1ed2a300 R15: 0000000000022000 Allocated by task 4428: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:196 [inline] __do_kmalloc_node mm/slab_common.c:967 [inline] __kmalloc+0xb9/0x230 mm/slab_common.c:980 kmalloc include/linux/slab.h:584 [inline] kzalloc include/linux/slab.h:720 [inline] tomoyo_encode2 security/tomoyo/realpath.c:45 [inline] tomoyo_encode+0x26f/0x530 security/tomoyo/realpath.c:80 tomoyo_realpath_from_path+0x598/0x5e0 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x254/0x4e0 security/tomoyo/file.c:771 security_file_open+0x63/0xa0 security/security.c:1719 do_dentry_open+0x308/0x10f0 fs/open.c:907 do_open fs/namei.c:3560 [inline] path_openat+0x27b3/0x3170 fs/namei.c:3715 do_filp_open+0x234/0x490 fs/namei.c:3742 do_sys_openat2+0x13f/0x500 fs/open.c:1348 do_sys_open fs/open.c:1364 [inline] __do_sys_openat fs/open.c:1380 [inline] __se_sys_openat fs/open.c:1375 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1375 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 4428: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0x264/0x3c0 mm/slub.c:3800 tomoyo_check_open_permission+0x3b7/0x4e0 security/tomoyo/file.c:786 security_file_open+0x63/0xa0 security/security.c:1719 do_dentry_open+0x308/0x10f0 fs/open.c:907 do_open fs/namei.c:3560 [inline] path_openat+0x27b3/0x3170 fs/namei.c:3715 do_filp_open+0x234/0x490 fs/namei.c:3742 do_sys_openat2+0x13f/0x500 fs/open.c:1348 do_sys_open fs/open.c:1364 [inline] __do_sys_openat fs/open.c:1380 [inline] __se_sys_openat fs/open.c:1375 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1375 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88807d7ae000 which belongs to the cache kmalloc-64 of size 64 The buggy address is located 48 bytes inside of freed 64-byte region [ffff88807d7ae000, ffff88807d7ae040) The buggy address belongs to the physical page: page:ffffea0001f5eb80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7d7ae flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888012441640 ffffea0001ed6d00 dead000000000004 raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 5508, tgid 5507 (syz-executor.5), ts 216596681888, free_ts 216594421954 prep_new_page mm/page_alloc.c:2553 [inline] get_page_from_freelist+0x3246/0x33c0 mm/page_alloc.c:4326 __alloc_pages+0x255/0x670 mm/page_alloc.c:5592 alloc_slab_page+0x6a/0x160 mm/slub.c:1851 allocate_slab mm/slub.c:1998 [inline] new_slab+0x84/0x2f0 mm/slub.c:2051 ___slab_alloc+0xa85/0x10a0 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] __kmem_cache_alloc_node+0x1b8/0x290 mm/slub.c:3491 kmalloc_trace+0x2a/0xe0 mm/slab_common.c:1061 kmalloc include/linux/slab.h:580 [inline] btrfs_ref_tree_mod+0x67d/0x1510 fs/btrfs/ref-verify.c:768 btrfs_free_tree_block+0x361/0xd30 fs/btrfs/extent-tree.c:3281 __btrfs_cow_block+0xcaa/0x1830 fs/btrfs/ctree.c:613 btrfs_cow_block+0x403/0x780 fs/btrfs/ctree.c:696 btrfs_search_slot+0xc89/0x2f70 fs/btrfs/ctree.c:2136 del_balance_item fs/btrfs/volumes.c:3518 [inline] reset_balance_state+0x1e5/0x3a0 fs/btrfs/volumes.c:3593 btrfs_balance+0xf17/0x1120 fs/btrfs/volumes.c:4431 btrfs_ioctl_balance+0x493/0x7c0 fs/btrfs/ioctl.c:3592 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1454 [inline] free_pcp_prepare mm/page_alloc.c:1504 [inline] free_unref_page_prepare+0xe2f/0xe70 mm/page_alloc.c:3388 free_unref_page+0x37/0x3f0 mm/page_alloc.c:3483 vfree+0x186/0x2e0 mm/vmalloc.c:2742 delayed_vfree_work+0x56/0x80 mm/vmalloc.c:2663 process_one_work+0x8a0/0x10e0 kernel/workqueue.c:2390 worker_thread+0xa63/0x1210 kernel/workqueue.c:2537 kthread+0x270/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Memory state around the buggy address: ffff88807d7adf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88807d7adf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88807d7ae000: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ^ ffff88807d7ae080: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88807d7ae100: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ==================================================================