syzbot


KASAN: use-after-free Read in z_erofs_transform_plain

Status: upstream: reported C repro on 2025/06/24 12:21
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+a94f033f5bdbb0bd6999@syzkaller.appspotmail.com
First crash: 23d, last: 14d
Fix commit to backport (bisect log) :
tree: upstream
commit 1ca01520148af399899ed66af5c78330bb9ecaf2
Author: Gao Xiang <hsiangkao@linux.alibaba.com>
Date: Wed Dec 6 09:10:56 2023 +0000

  erofs: refine z_erofs_transform_plain() for sub-page block support

  
Bug presence (2)
Date Name Commit Repro Result
2025/06/27 linux-6.6.y (ToT) 6282921b6825 C [report] KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/06/27 upstream (ToT) 67a993863163 C Didn't crash
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in z_erofs_transform_plain origin:lts-only 19 C inconclusive 140 4d06h 527d 0/3 upstream: reported C repro on 2024/02/07 05:17
upstream KASAN: use-after-free Read in z_erofs_transform_plain erofs 19 C done 4 879d 955d 22/29 fixed on 2023/02/24 13:50
Fix bisection attempts (1)
Created Duration User Patch Repo Result
2025/07/11 02:01 9h29m fix candidate upstream OK (1) job log

Sample crash report:
loop0: rw=524288, sector=720, nr_sectors = 16 limit=16
syz-executor150: attempt to access beyond end of device
loop0: rw=524288, sector=525144, nr_sectors = 16 limit=16
syz-executor150: attempt to access beyond end of device
loop0: rw=524288, sector=16, nr_sectors = 8 limit=16
syz-executor150: attempt to access beyond end of device
loop0: rw=524288, sector=13716630376, nr_sectors = 8 limit=16
==================================================================
BUG: KASAN: slab-use-after-free in memcpy_to_page include/linux/highmem.h:427 [inline]
BUG: KASAN: slab-use-after-free in z_erofs_transform_plain+0x38c/0x460 fs/erofs/decompressor.c:346
Read of size 4095 at addr ffff88807b8d7400 by task syz-executor150/5769

CPU: 0 PID: 5769 Comm: syz-executor150 Not tainted 6.6.94-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x230 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xac/0x230 mm/kasan/report.c:475
 kasan_report+0x117/0x150 mm/kasan/report.c:588
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x288/0x290 mm/kasan/generic.c:187
 __asan_memcpy+0x29/0x70 mm/kasan/shadow.c:105
 memcpy_to_page include/linux/highmem.h:427 [inline]
 z_erofs_transform_plain+0x38c/0x460 fs/erofs/decompressor.c:346
 z_erofs_decompress_pcluster fs/erofs/zdata.c:1290 [inline]
 z_erofs_decompress_queue+0x16fb/0x2650 fs/erofs/zdata.c:1371
 z_erofs_runqueue+0x18a3/0x19d0 fs/erofs/zdata.c:1759
 z_erofs_readahead+0xa7c/0xd50 fs/erofs/zdata.c:1888
 read_pages+0x177/0x840 mm/readahead.c:160
 page_cache_ra_unbounded+0x692/0x770 mm/readahead.c:269
 do_page_cache_ra mm/readahead.c:299 [inline]
 force_page_cache_ra+0x2c1/0x320 mm/readahead.c:330
 force_page_cache_readahead mm/internal.h:175 [inline]
 generic_fadvise+0x44f/0x730 mm/fadvise.c:106
 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+0x140/0x180 mm/fadvise.c:212
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f16442791f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 1f 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffee6c44908 EFLAGS: 00000246 ORIG_RAX: 00000000000000dd
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f16442791f9
RDX: 000000000000ff39 RSI: 000000000000aa1f RDI: 0000000000000004
RBP: 00007f16442c660e R08: 00007f16442c663e R09: 00007f16442c663e
R10: 0000000000000003 R11: 0000000000000246 R12: 00007f16442c658f
R13: 0000000000000003 R14: 0000000000050012 R15: 00007f16442fc740
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001ee35c0 refcount:2 mapcount:0 mapping:ffff888073db87c8 index:0x1 pfn:0x7b8d7
memcg:ffff88814125a000
aops:z_erofs_cache_aops ino:0
flags: 0xfff40000008028(uptodate|lru|private|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff40000008028 ffffea0001ee3588 ffffea0000954208 ffff888073db87c8
raw: 0000000000000001 ffff888073db4000 00000002ffffffff ffff88814125a000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x92840(GFP_NOWAIT|__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_NOMEMALLOC), pid 5769, tgid 5769 (syz-executor150), ts 84628441673, free_ts 64645641726
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1cd/0x210 mm/page_alloc.c:1554
 prep_new_page mm/page_alloc.c:1561 [inline]
 get_page_from_freelist+0x195c/0x19f0 mm/page_alloc.c:3191
 __alloc_pages+0x1e3/0x460 mm/page_alloc.c:4457
 z_erofs_bind_cache fs/erofs/zdata.c:599 [inline]
 z_erofs_pcluster_begin fs/erofs/zdata.c:883 [inline]
 z_erofs_do_read_page+0x20c0/0x3680 fs/erofs/zdata.c:1018
 z_erofs_read_folio+0x213/0x540 fs/erofs/zdata.c:1839
 filemap_read_folio+0x167/0x760 mm/filemap.c:2420
 do_read_cache_folio+0x470/0x7e0 mm/filemap.c:3789
 erofs_bread+0x16f/0x630 fs/erofs/data.c:48
 erofs_find_target_block fs/erofs/namei.c:103 [inline]
 erofs_namei+0x28c/0xf00 fs/erofs/namei.c:177
 erofs_lookup+0x135/0x310 fs/erofs/namei.c:206
 __lookup_slow+0x281/0x3b0 fs/namei.c:1694
 lookup_slow+0x53/0x70 fs/namei.c:1711
 walk_component fs/namei.c:2002 [inline]
 link_path_walk+0x970/0xe00 fs/namei.c:2329
 path_openat+0x283/0x3190 fs/namei.c:3785
 do_filp_open+0x1c5/0x3d0 fs/namei.c:3816
 do_sys_openat2+0x12c/0x1c0 fs/open.c:1419
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1154 [inline]
 free_unref_page_prepare+0x7ce/0x8e0 mm/page_alloc.c:2336
 free_unref_page+0x32/0x2e0 mm/page_alloc.c:2429
 discard_slab mm/slub.c:2122 [inline]
 __unfreeze_partials+0x1cf/0x210 mm/slub.c:2662
 put_cpu_partial+0x17c/0x250 mm/slub.c:2738
 __slab_free+0x31d/0x410 mm/slub.c:3686
 qlink_free mm/kasan/quarantine.c:166 [inline]
 qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x143/0x160 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6e/0x4d0 mm/slab.h:767
 slab_alloc_node mm/slub.c:3485 [inline]
 __kmem_cache_alloc_node+0x13e/0x260 mm/slub.c:3524
 __do_kmalloc_node mm/slab_common.c:1006 [inline]
 __kmalloc+0xa4/0x240 mm/slab_common.c:1020
 kmalloc include/linux/slab.h:604 [inline]
 tomoyo_realpath_from_path+0xe3/0x5d0 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x20f/0x4b0 security/tomoyo/file.c:822
 security_inode_getattr+0xd3/0x120 security/security.c:2153
 vfs_getattr fs/stat.c:173 [inline]
 vfs_fstat fs/stat.c:198 [inline]
 __do_sys_newfstat fs/stat.c:473 [inline]
 __se_sys_newfstat fs/stat.c:470 [inline]
 __x64_sys_newfstat+0x101/0x1f0 fs/stat.c:470
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81

Memory state around the buggy address:
 ffff88807b8d7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88807b8d7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88807b8d8000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88807b8d8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807b8d8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (21):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/26 03:12 linux-6.6.y 6282921b6825 26d77996 .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/07/01 22:12 linux-6.6.y 3f5b4c104b7d 091a06cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2025/06/24 12:21 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: use-after-free Read in z_erofs_transform_plain
2025/07/03 10:22 linux-6.6.y 3f5b4c104b7d 115ceea7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/07/03 10:19 linux-6.6.y 3f5b4c104b7d 115ceea7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/07/03 10:19 linux-6.6.y 3f5b4c104b7d 115ceea7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/07/02 05:45 linux-6.6.y 3f5b4c104b7d bc80e4f0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/07/01 22:19 linux-6.6.y 3f5b4c104b7d 091a06cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/07/01 22:15 linux-6.6.y 3f5b4c104b7d 091a06cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/07/01 22:15 linux-6.6.y 3f5b4c104b7d 091a06cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/07/01 09:06 linux-6.6.y 3f5b4c104b7d 6e83b42d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/06/27 08:19 linux-6.6.y 6282921b6825 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/27 08:18 linux-6.6.y 6282921b6825 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/27 07:58 linux-6.6.y 6282921b6825 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/06/27 07:55 linux-6.6.y 6282921b6825 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/27 07:55 linux-6.6.y 6282921b6825 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/24 12:31 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/24 12:30 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/06/24 12:25 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in z_erofs_transform_plain
2025/06/24 12:25 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
2025/06/24 12:21 linux-6.6.y 6282921b6825 e2f27c35 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-out-of-bounds Read in z_erofs_transform_plain
* Struck through repros no longer work on HEAD.