erofs: (device loop5): z_erofs_readahead: readahead error at page 2 @ nid 89 erofs: (device loop5): z_erofs_readahead: readahead error at page 1 @ nid 89 ================================================================== BUG: KASAN: use-after-free in z_erofs_transform_plain+0x379/0x470 fs/erofs/decompressor.c:355 Read of size 4096 at addr ffff88802f5b8000 by task syz-executor.5/27808 CPU: 1 PID: 27808 Comm: syz-executor.5 Not tainted 6.2.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/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:306 [inline] print_report+0x163/0x4f0 mm/kasan/report.c:417 kasan_report+0x13a/0x170 mm/kasan/report.c:517 kasan_check_range+0x283/0x290 mm/kasan/generic.c:189 memcpy+0x29/0x70 mm/kasan/shadow.c:65 z_erofs_transform_plain+0x379/0x470 fs/erofs/decompressor.c:355 z_erofs_decompress_pcluster fs/erofs/zdata.c:1054 [inline] z_erofs_decompress_queue+0x1914/0x2af0 fs/erofs/zdata.c:1141 z_erofs_runqueue+0x1a65/0x1c40 fs/erofs/zdata.c:1522 z_erofs_read_folio+0x4e8/0x830 fs/erofs/zdata.c:1617 filemap_read_folio+0x19d/0x7a0 mm/filemap.c:2426 filemap_update_page mm/filemap.c:2511 [inline] filemap_get_pages mm/filemap.c:2625 [inline] filemap_read+0x1a17/0x3200 mm/filemap.c:2695 __kernel_read+0x422/0x8a0 fs/read_write.c:428 integrity_kernel_read+0xb0/0xf0 security/integrity/iint.c:199 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:485 [inline] ima_calc_file_shash security/integrity/ima/ima_crypto.c:516 [inline] ima_calc_file_hash+0xa5b/0x1c00 security/integrity/ima/ima_crypto.c:573 ima_collect_measurement+0x4cd/0x930 security/integrity/ima/ima_api.c:292 process_measurement+0xf83/0x1c30 security/integrity/ima/ima_main.c:339 ima_file_check+0xec/0x170 security/integrity/ima/ima_main.c:519 do_open fs/namei.c:3559 [inline] path_openat+0x265d/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_open fs/open.c:1334 [inline] __se_sys_open fs/open.c:1330 [inline] __x64_sys_open+0x225/0x270 fs/open.c:1330 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:0x7ff03188c0f9 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:00007ff032681168 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 00007ff0319abf80 RCX: 00007ff03188c0f9 RDX: 0000000000000000 RSI: 0000000000000074 RDI: 0000000020007280 RBP: 00007ff0318e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffdbfb2726f R14: 00007ff032681300 R15: 0000000000022000 Allocated by task 4425: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x80 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x9b/0xb0 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slab_common.c:968 [inline] __kmalloc+0xb3/0x1a0 mm/slab_common.c:981 kmalloc include/linux/slab.h:584 [inline] tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251 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:1718 do_dentry_open+0x308/0x10f0 fs/open.c:869 do_open fs/namei.c:3557 [inline] path_openat+0x2606/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1337 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 4425: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x80 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:523 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:177 [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_realpath_from_path+0x5a3/0x5e0 security/tomoyo/realpath.c:286 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:1718 do_dentry_open+0x308/0x10f0 fs/open.c:869 do_open fs/namei.c:3557 [inline] path_openat+0x2606/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1337 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 ffff88802f5b8000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 0 bytes inside of 4096-byte region [ffff88802f5b8000, ffff88802f5b9000) The buggy address belongs to the physical page: page:ffffea0000bd6e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2f5b8 head:ffffea0000bd6e00 order:3 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff888012442140 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4425, tgid 4425 (udevd), ts 364848654354, free_ts 364588855021 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x3449/0x35c0 mm/page_alloc.c:4283 __alloc_pages+0x291/0x7e0 mm/page_alloc.c:5549 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/0x2a0 mm/slub.c:3491 __do_kmalloc_node mm/slab_common.c:967 [inline] __kmalloc+0xa2/0x1a0 mm/slab_common.c:981 kmalloc include/linux/slab.h:584 [inline] tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x28d/0x700 security/tomoyo/file.c:822 security_inode_getattr+0xd3/0x120 security/security.c:1375 vfs_getattr fs/stat.c:161 [inline] vfs_statx+0x18f/0x480 fs/stat.c:236 vfs_fstatat fs/stat.c:270 [inline] __do_sys_newfstatat fs/stat.c:440 [inline] __se_sys_newfstatat+0x108/0x7c0 fs/stat.c:434 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 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_pcp_prepare mm/page_alloc.c:1496 [inline] free_unref_page_prepare+0xf3a/0x1040 mm/page_alloc.c:3369 free_unref_page+0x37/0x3f0 mm/page_alloc.c:3464 discard_slab mm/slub.c:2098 [inline] __unfreeze_partials+0x1b1/0x1f0 mm/slub.c:2637 put_cpu_partial+0x116/0x180 mm/slub.c:2713 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook+0x68/0x390 mm/slab.h:761 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+0x12c/0x280 mm/slub.c:3476 alloc_extent_state+0x22/0x430 fs/btrfs/extent-io-tree.c:146 __set_extent_bit+0x218/0x1b60 fs/btrfs/extent-io-tree.c:998 lock_extent+0x10a/0x280 fs/btrfs/extent-io-tree.c:1735 btrfs_finish_ordered_io+0x66b/0x1c60 fs/btrfs/inode.c:3300 btrfs_work_helper+0x43a/0xe90 fs/btrfs/async-thread.c:280 process_one_work+0x8fa/0x1370 kernel/workqueue.c:2289 worker_thread+0xa63/0x1210 kernel/workqueue.c:2436 Memory state around the buggy address: ffff88802f5b7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88802f5b7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88802f5b8000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88802f5b8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88802f5b8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================