erofs: (device loop1): z_erofs_readahead: readahead error at page 45 @ nid 36 syz.1.42: attempt to access beyond end of device loop1: rw=524288, sector=32, nr_sectors = 64 limit=16 syz.1.42: attempt to access beyond end of device loop1: rw=524288, sector=16, nr_sectors = 16 limit=16 syz.1.42: attempt to access beyond end of device loop1: rw=524288, sector=14425508768, nr_sectors = 8 limit=16 ================================================================== BUG: KASAN: use-after-free in z_erofs_transform_plain+0x375/0x470 fs/erofs/decompressor.c:350 Read of size 1622 at addr ffff88805da14e5b by task syz.1.42/3947 CPU: 0 PID: 3947 Comm: syz.1.42 Not tainted 6.1.110-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 kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189 memcpy+0x25/0x60 mm/kasan/shadow.c:65 z_erofs_transform_plain+0x375/0x470 fs/erofs/decompressor.c:350 z_erofs_decompress_pcluster fs/erofs/zdata.c:1173 [inline] z_erofs_decompress_queue+0x1aa0/0x2d50 fs/erofs/zdata.c:1256 z_erofs_runqueue+0x1a6e/0x1ca0 fs/erofs/zdata.c:1614 z_erofs_readahead+0xc26/0x1030 fs/erofs/zdata.c:1758 read_pages+0x17f/0x830 mm/readahead.c:161 page_cache_ra_unbounded+0x68b/0x7b0 mm/readahead.c:270 do_page_cache_ra mm/readahead.c:300 [inline] force_page_cache_ra+0x2a3/0x300 mm/readahead.c:331 force_page_cache_readahead mm/internal.h:106 [inline] generic_fadvise+0x553/0x7b0 mm/fadvise.c:107 vfs_fadvise mm/fadvise.c:185 [inline] ksys_fadvise64_64 mm/fadvise.c:199 [inline] __do_sys_fadvise64 mm/fadvise.c:214 [inline] __se_sys_fadvise64 mm/fadvise.c:212 [inline] __x64_sys_fadvise64+0x138/0x180 mm/fadvise.c:212 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:0x7ffad6f7def9 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:00007ffad7d45038 EFLAGS: 00000246 ORIG_RAX: 00000000000000dd RAX: ffffffffffffffda RBX: 00007ffad7136058 RCX: 00007ffad6f7def9 RDX: 0000000000000000 RSI: 000000000000fcff RDI: 0000000000000009 RBP: 00007ffad6ff0b76 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007ffad7136058 R15: 00007ffe6c948e08 The buggy address belongs to the physical page: page:ffffea0001768500 refcount:2 mapcount:0 mapping:ffff888071ef07c8 index:0x1 pfn:0x5da14 memcg:ffff8880776bc000 aops:managed_cache_aops ino:0 flags: 0xfff40000002014(uptodate|lru|private|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff40000002014 ffffea000158b088 ffffea0001491988 ffff888071ef07c8 raw: 0000000000000001 ffff888071f55000 00000002ffffffff ffff8880776bc000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x192840(GFP_NOWAIT|__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3944, tgid 3943 (syz.1.42), ts 70533164712, free_ts 67416108536 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 z_erofs_bind_cache fs/erofs/zdata.c:482 [inline] z_erofs_do_read_page+0x1a76/0x3bd0 fs/erofs/zdata.c:858 z_erofs_read_folio+0x31a/0x760 fs/erofs/zdata.c:1703 filemap_read_folio+0x199/0x780 mm/filemap.c:2461 do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3598 erofs_bread+0x149/0x610 fs/erofs/data.c:46 find_target_block_classic fs/erofs/namei.c:108 [inline] erofs_namei+0x1ad/0xca0 fs/erofs/namei.c:184 erofs_lookup+0x1d6/0x4d0 fs/erofs/namei.c:212 lookup_open fs/namei.c:3462 [inline] open_last_lookups fs/namei.c:3552 [inline] path_openat+0x10fb/0x2e60 fs/namei.c:3782 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 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+0x33/0x3e0 mm/page_alloc.c:3464 __vunmap+0x834/0x9a0 mm/vmalloc.c:2717 free_work+0x57/0x80 mm/vmalloc.c:97 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439 kthread+0x28d/0x320 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff88805da14f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88805da14f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88805da15000: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff88805da15080: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88805da15100: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc ==================================================================