loop0: detected capacity change from 0 to 16 erofs: (device loop0): mounted with root inode @ nid 36. ================================================================== BUG: KASAN: use-after-free in z_erofs_transform_plain+0x359/0x430 fs/erofs/decompressor.c:355 Read of size 4096 at addr ffff888077a94000 by task syz-executor.0/23719 CPU: 1 PID: 23719 Comm: syz-executor.0 Not tainted 6.1.0-rc7-syzkaller-00123-ga4412fdd49dc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:284 print_report+0x107/0x220 mm/kasan/report.c:395 kasan_report+0x139/0x170 mm/kasan/report.c:495 kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189 memcpy+0x25/0x60 mm/kasan/shadow.c:65 z_erofs_transform_plain+0x359/0x430 fs/erofs/decompressor.c:355 z_erofs_decompress_pcluster fs/erofs/zdata.c:1068 [inline] z_erofs_decompress_queue+0x18f9/0x2c10 fs/erofs/zdata.c:1155 z_erofs_runqueue fs/erofs/zdata.c:1536 [inline] z_erofs_read_folio+0x458/0x640 fs/erofs/zdata.c:1631 filemap_read_folio+0x1ba/0x7f0 mm/filemap.c:2407 filemap_update_page+0x3ca/0x550 mm/filemap.c:2492 filemap_get_pages+0x8d8/0x1110 mm/filemap.c:2605 filemap_read+0x3e7/0xee0 mm/filemap.c:2675 __kernel_read+0x3c4/0x7e0 fs/read_write.c:428 integrity_kernel_read+0xac/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+0x17d1/0x1cb0 security/integrity/ima/ima_crypto.c:573 ima_collect_measurement+0x47f/0x8d0 security/integrity/ima/ima_api.c:292 process_measurement+0xd60/0x1b10 security/integrity/ima/ima_main.c:337 ima_file_check+0xe7/0x160 security/integrity/ima/ima_main.c:517 do_open fs/namei.c:3559 [inline] path_openat+0x2654/0x2e00 fs/namei.c:3714 do_filp_open+0x275/0x500 fs/namei.c:3741 do_sys_openat2+0x13b/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+0x221/0x270 fs/open.c:1330 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7faaea28c0d9 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:00007faaeaf66168 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 00007faaea3abf80 RCX: 00007faaea28c0d9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000100 RBP: 00007faaea2e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff15d936af R14: 00007faaeaf66300 R15: 0000000000022000 Allocated by task 8465: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:52 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:325 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:737 [inline] slab_alloc_node mm/slub.c:3398 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc+0x1cc/0x300 mm/slub.c:3422 kmem_cache_zalloc include/linux/slab.h:679 [inline] __alloc_file+0x26/0x230 fs/file_table.c:138 alloc_empty_file+0xa9/0x1b0 fs/file_table.c:187 path_openat+0xf1/0x2e00 fs/namei.c:3700 do_filp_open+0x275/0x500 fs/namei.c:3741 do_sys_openat2+0x13b/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+0x243/0x290 fs/open.c:1337 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 21: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:511 ____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:1724 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750 slab_free mm/slub.c:3661 [inline] kmem_cache_free+0x94/0x1d0 mm/slub.c:3683 rcu_do_batch kernel/rcu/tree.c:2250 [inline] rcu_core+0xa91/0x1790 kernel/rcu/tree.c:2510 __do_softirq+0x277/0x75b kernel/softirq.c:571 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:481 call_rcu+0x163/0xa00 kernel/rcu/tree.c:2798 task_work_run+0x243/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x134/0x160 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xad/0x110 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x2e/0x60 kernel/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:481 task_work_add+0x87/0x340 kernel/task_work.c:48 fput+0xdc/0x1a0 fs/file_table.c:376 filp_close+0x10a/0x150 fs/open.c:1426 __do_sys_close fs/open.c:1439 [inline] __se_sys_close fs/open.c:1437 [inline] __x64_sys_close+0x34/0x90 fs/open.c:1437 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888077a94000 which belongs to the cache filp of size 456 The buggy address is located 0 bytes inside of 456-byte region [ffff888077a94000, ffff888077a941c8) The buggy address belongs to the physical page: page:ffffea0001dea500 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888077a94f00 pfn:0x77a94 head:ffffea0001dea500 order:1 compound_mapcount:0 compound_pincount:0 memcg:ffff8880760f2381 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0001e9c488 ffffea000087b588 ffff8880129e0b40 raw: ffff888077a94f00 00000000000c0009 00000001ffffffff ffff8880760f2381 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3685, tgid 3685 (syz-executor.1), ts 599598386372, free_ts 594639155713 prep_new_page mm/page_alloc.c:2539 [inline] get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4291 __alloc_pages+0x259/0x560 mm/page_alloc.c:5558 alloc_slab_page+0x70/0xf0 mm/slub.c:1794 allocate_slab+0x5e/0x4b0 mm/slub.c:1939 new_slab mm/slub.c:1992 [inline] ___slab_alloc+0x7f4/0xeb0 mm/slub.c:3180 __slab_alloc mm/slub.c:3279 [inline] slab_alloc_node mm/slub.c:3364 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc+0x24c/0x300 mm/slub.c:3422 kmem_cache_zalloc include/linux/slab.h:679 [inline] __alloc_file+0x26/0x230 fs/file_table.c:138 alloc_empty_file+0xa9/0x1b0 fs/file_table.c:187 alloc_file+0x58/0x5e0 fs/file_table.c:229 alloc_file_pseudo+0x260/0x300 fs/file_table.c:272 sock_alloc_file+0xb4/0x240 net/socket.c:463 sock_map_fd net/socket.c:487 [inline] __sys_socket+0x1cb/0x3a0 net/socket.c:1644 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x76/0x80 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 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:1459 [inline] free_pcp_prepare+0x80c/0x8f0 mm/page_alloc.c:1509 free_unref_page_prepare mm/page_alloc.c:3387 [inline] free_unref_page+0x7d/0x630 mm/page_alloc.c:3483 qlist_free_all+0x2b/0x70 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:302 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:737 [inline] slab_alloc_node mm/slub.c:3398 [inline] slab_alloc mm/slub.c:3406 [inline] __kmem_cache_alloc_lru mm/slub.c:3413 [inline] kmem_cache_alloc+0x1cc/0x300 mm/slub.c:3422 getname_flags+0xb8/0x4e0 fs/namei.c:139 vfs_fstatat fs/stat.c:266 [inline] __do_sys_newfstatat fs/stat.c:437 [inline] __se_sys_newfstatat+0xe2/0x7b0 fs/stat.c:431 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888077a93f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888077a93f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff888077a94000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888077a94080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888077a94100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================