syz.5.3090: attempt to access beyond end of device loop5: rw=524288, sector=16, nr_sectors = 16 limit=16 syz.5.3090: attempt to access beyond end of device loop5: 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 ffff888051d75e5b by task syz.5.3090/18193 CPU: 0 PID: 18193 Comm: syz.5.3090 Not tainted 6.1.119-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:1175 [inline] z_erofs_decompress_queue+0x1aa0/0x2d50 fs/erofs/zdata.c:1258 z_erofs_runqueue+0x1bfe/0x1e10 fs/erofs/zdata.c:1616 z_erofs_readahead+0xc26/0x1030 fs/erofs/zdata.c:1760 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:125 [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:0x7f498c17ff19 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:00007f498cf35058 EFLAGS: 00000246 ORIG_RAX: 00000000000000dd RAX: ffffffffffffffda RBX: 00007f498c345fa0 RCX: 00007f498c17ff19 RDX: 040000000001060f RSI: 0000000000000004 RDI: 0000000000000004 RBP: 00007f498c1f3986 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f498c345fa0 R15: 00007ffd3e667bb8 The buggy address belongs to the physical page: page:ffffea0001475d40 refcount:2 mapcount:0 mapping:ffff8880463ea280 index:0x1 pfn:0x51d75 memcg:ffff888076c12000 aops:managed_cache_aops ino:0 flags: 0xfff40000002014(uptodate|lru|private|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff40000002014 ffffea0001488c48 ffffea00012606c8 ffff8880463ea280 raw: 0000000000000001 ffff8880550c4270 00000002ffffffff ffff888076c12000 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 18193, tgid 18192 (syz.5.3090), ts 1019388332018, free_ts 1019201044018 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+0x3731/0x38d0 mm/page_alloc.c:4313 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5590 z_erofs_bind_cache fs/erofs/zdata.c:482 [inline] z_erofs_do_read_page+0x19da/0x3d00 fs/erofs/zdata.c:860 z_erofs_read_folio+0x31a/0x760 fs/erofs/zdata.c:1705 filemap_read_folio+0x199/0x780 mm/filemap.c:2489 do_read_cache_folio+0x2ee/0x810 mm/filemap.c:3626 erofs_bread+0x19d/0x6b0 fs/erofs/data.c:50 erofs_find_target_block fs/erofs/namei.c:102 [inline] erofs_namei+0x278/0xef0 fs/erofs/namei.c:175 erofs_lookup+0x1d6/0x4d0 fs/erofs/namei.c:204 lookup_open fs/namei.c:3460 [inline] open_last_lookups fs/namei.c:3550 [inline] path_openat+0x10fb/0x2e60 fs/namei.c:3780 do_filp_open+0x230/0x480 fs/namei.c:3810 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 tlb_batch_list_free mm/mmu_gather.c:75 [inline] tlb_finish_mmu+0x119/0x1f0 mm/mmu_gather.c:364 exit_mmap+0x3b3/0x980 mm/mmap.c:3246 __mmput+0x115/0x3c0 kernel/fork.c:1200 exit_mm+0x226/0x300 kernel/exit.c:565 do_exit+0x9f6/0x26a0 kernel/exit.c:858 do_group_exit+0x202/0x2b0 kernel/exit.c:1021 get_signal+0x16f7/0x17d0 kernel/signal.c:2871 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:871 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:174 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 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Memory state around the buggy address: ffff888051d75f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888051d75f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888051d76000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff888051d76080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff888051d76100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================