* [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
@ 2025-08-22 18:55 syzbot
2025-08-22 19:46 ` syzbot
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: syzbot @ 2025-08-22 18:55 UTC (permalink / raw)
To: chao, dhavale, jefflexu, lihongbo22, linux-erofs, linux-kernel,
syzkaller-bugs, xiang, zbestahu
Hello,
syzbot found the following issue on:
HEAD commit: 3957a5720157 Merge tag 'cgroup-for-6.17-rc2-fixes' of git:..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=104f0062580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16650c42580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1277dfa2580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c5cbe8650b9a/disk-3957a572.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/51911bea9855/vmlinux-3957a572.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b07279b5fcc2/bzImage-3957a572.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/b6ca0d9a661b/mount_0.gz
fsck result: failed (log: https://syzkaller.appspot.com/x/fsck.log?x=142187bc580000)
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
==================================================================
BUG: KASAN: global-out-of-bounds in z_erofs_decompress_pcluster fs/erofs/zdata.c:1274 [inline]
BUG: KASAN: global-out-of-bounds in z_erofs_decompress_queue+0x341/0x3580 fs/erofs/zdata.c:1411
Read of size 8 at addr ffffffff8e05df10 by task kworker/u9:1/5152
CPU: 1 UID: 0 PID: 5152 Comm: kworker/u9:1 Tainted: G W syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Workqueue: erofs_worker z_erofs_decompressqueue_work
Call Trace:
<TASK>
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xca/0x240 mm/kasan/report.c:482
kasan_report+0x118/0x150 mm/kasan/report.c:595
z_erofs_decompress_pcluster fs/erofs/zdata.c:1274 [inline]
z_erofs_decompress_queue+0x341/0x3580 fs/erofs/zdata.c:1411
z_erofs_decompressqueue_work+0x82/0xd0 fs/erofs/zdata.c:1423
process_one_work kernel/workqueue.c:3236 [inline]
process_scheduled_works+0xade/0x17b0 kernel/workqueue.c:3319
worker_thread+0x8a0/0xda0 kernel/workqueue.c:3400
kthread+0x70e/0x8a0 kernel/kthread.c:463
ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
The buggy address belongs to the variable:
z_erofs_decomp+0x30/0xe0
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xe05d
flags: 0x80000000002000(reserved|node=0|zone=1)
raw: 0080000000002000 ffffea0000381748 ffffea0000381748 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner info is not present (never set?)
Memory state around the buggy address:
ffffffff8e05de00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffff8e05de80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffffff8e05df00: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
^
ffffffff8e05df80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffff8e05e000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
@ 2025-08-22 19:46 ` syzbot
2025-08-23 0:53 ` Edward Adam Davis
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: syzbot @ 2025-08-22 19:46 UTC (permalink / raw)
To: chao, dhavale, hsiangkao, jefflexu, lihongbo22, linux-erofs,
linux-kernel, syzkaller-bugs, xiang, zbestahu
syzbot has bisected this issue to:
commit df0ce6cefa453d2236381645e529a27ef2f0a573
Author: Chao Yu <chao@kernel.org>
Date: Mon Jul 21 02:13:52 2025 +0000
erofs: support to readahead dirent blocks in erofs_readdir()
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12e047bc580000
start commit: 3957a5720157 Merge tag 'cgroup-for-6.17-rc2-fixes' of git:..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=11e047bc580000
console output: https://syzkaller.appspot.com/x/log.txt?x=16e047bc580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=151b07bc580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=131b07bc580000
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Fixes: df0ce6cefa45 ("erofs: support to readahead dirent blocks in erofs_readdir()")
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
2025-08-22 19:46 ` syzbot
@ 2025-08-23 0:53 ` Edward Adam Davis
2025-08-23 1:09 ` syzbot
2025-08-23 1:22 ` Edward Adam Davis
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Edward Adam Davis @ 2025-08-23 0:53 UTC (permalink / raw)
To: syzbot+5a398eb460ddaa6f242f; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 2d73297003d2..11f59bc2db8e 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -752,6 +752,10 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
lockref_init(&pcl->lockref); /* one ref for this request */
pcl->algorithmformat = map->m_algorithmformat;
+ if (pcl->algorithmformat >= Z_EROFS_COMPRESSION_MAX) {
+ err = -EINVAL;
+ goto out;
+ }
pcl->pclustersize = map->m_plen;
pcl->length = 0;
pcl->partial = true;
@@ -796,6 +800,7 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
err_out:
mutex_unlock(&pcl->lock);
+out:
z_erofs_free_pcluster(pcl);
return err;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-23 0:53 ` Edward Adam Davis
@ 2025-08-23 1:09 ` syzbot
0 siblings, 0 replies; 12+ messages in thread
From: syzbot @ 2025-08-23 1:09 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: invalid-free in z_erofs_scan_folio
erofs (device loop0): mounted with root inode @ nid 36.
erofs (device loop0): readahead error at folio 7 @ nid 36
erofs (device loop0): readahead error at folio 6 @ nid 36
erofs (device loop0): readahead error at folio 5 @ nid 36
erofs (device loop0): readahead error at folio 4 @ nid 36
erofs (device loop0): readahead error at folio 3 @ nid 36
==================================================================
BUG: KASAN: invalid-free in z_erofs_free_pcluster fs/erofs/zdata.c:281 [inline]
BUG: KASAN: invalid-free in z_erofs_register_pcluster fs/erofs/zdata.c:804 [inline]
BUG: KASAN: invalid-free in z_erofs_pcluster_begin fs/erofs/zdata.c:840 [inline]
BUG: KASAN: invalid-free in z_erofs_scan_folio+0x1e4a/0x4540 fs/erofs/zdata.c:1056
Free of addr ffff8880565609d8 by task syz.0.17/6607
CPU: 1 UID: 0 PID: 6607 Comm: syz.0.17 Tainted: G W syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
<TASK>
dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xca/0x240 mm/kasan/report.c:482
kasan_report_invalid_free+0xea/0x110 mm/kasan/report.c:557
check_slab_allocation+0xe1/0x130 include/linux/page-flags.h:-1
kasan_slab_pre_free include/linux/kasan.h:198 [inline]
slab_free_hook mm/slub.c:2362 [inline]
slab_free mm/slub.c:4680 [inline]
kmem_cache_free+0x146/0x510 mm/slub.c:4782
z_erofs_free_pcluster fs/erofs/zdata.c:281 [inline]
z_erofs_register_pcluster fs/erofs/zdata.c:804 [inline]
z_erofs_pcluster_begin fs/erofs/zdata.c:840 [inline]
z_erofs_scan_folio+0x1e4a/0x4540 fs/erofs/zdata.c:1056
z_erofs_readahead+0x672/0xb40 fs/erofs/zdata.c:1922
read_pages+0x177/0x580 mm/readahead.c:160
page_cache_ra_unbounded+0x63b/0x740 mm/readahead.c:297
page_cache_sync_readahead include/linux/pagemap.h:1369 [inline]
erofs_readdir+0x567/0x1020 fs/erofs/dir.c:77
iterate_dir+0x3a2/0x580 fs/readdir.c:108
__do_sys_getdents fs/readdir.c:326 [inline]
__se_sys_getdents+0xe4/0x250 fs/readdir.c:312
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2826aaebe9
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:00007f2826116038 EFLAGS: 00000246 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007f2826cd5fa0 RCX: 00007f2826aaebe9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007f2826b31e19 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f2826cd6038 R14: 00007f2826cd5fa0 R15: 00007ffd944ac938
</TASK>
Allocated by task 6607:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:330 [inline]
__kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:356
kasan_slab_alloc include/linux/kasan.h:250 [inline]
slab_post_alloc_hook mm/slub.c:4180 [inline]
slab_alloc_node mm/slub.c:4229 [inline]
kmem_cache_alloc_noprof+0x143/0x310 mm/slub.c:4236
z_erofs_alloc_pcluster fs/erofs/zdata.c:262 [inline]
z_erofs_register_pcluster fs/erofs/zdata.c:749 [inline]
z_erofs_pcluster_begin fs/erofs/zdata.c:840 [inline]
z_erofs_scan_folio+0x162e/0x4540 fs/erofs/zdata.c:1056
z_erofs_readahead+0x672/0xb40 fs/erofs/zdata.c:1922
read_pages+0x177/0x580 mm/readahead.c:160
page_cache_ra_unbounded+0x63b/0x740 mm/readahead.c:297
page_cache_sync_readahead include/linux/pagemap.h:1369 [inline]
erofs_readdir+0x567/0x1020 fs/erofs/dir.c:77
iterate_dir+0x3a2/0x580 fs/readdir.c:108
__do_sys_getdents fs/readdir.c:326 [inline]
__se_sys_getdents+0xe4/0x250 fs/readdir.c:312
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff8880565609d8
which belongs to the cache erofs_pcluster-128 of size 2392
The buggy address is located 0 bytes inside of
2392-byte region [ffff8880565609d8, ffff888056561330)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x56560
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x80000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0080000000000040 ffff88802030f000 dead000000000122 0000000000000000
raw: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000
head: 0080000000000040 ffff88802030f000 dead000000000122 0000000000000000
head: 0000000000000000 00000000800d000d 00000000f5000000 0000000000000000
head: 0080000000000003 ffffea0001595801 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Reclaimable, gfp_mask 0xd2050(__GFP_RECLAIMABLE|__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6607, tgid 6606 (syz.0.17), ts 171069705490, free_ts 99313462986
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1851
prep_new_page mm/page_alloc.c:1859 [inline]
get_page_from_freelist+0x2119/0x21b0 mm/page_alloc.c:3858
__alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5148
alloc_pages_mpol+0xd1/0x380 mm/mempolicy.c:2416
alloc_slab_page mm/slub.c:2487 [inline]
allocate_slab+0x8a/0x370 mm/slub.c:2655
new_slab mm/slub.c:2709 [inline]
___slab_alloc+0x8d1/0xdd0 mm/slub.c:3891
__slab_alloc mm/slub.c:3981 [inline]
__slab_alloc_node mm/slub.c:4056 [inline]
slab_alloc_node mm/slub.c:4217 [inline]
kmem_cache_alloc_noprof+0xe6/0x310 mm/slub.c:4236
z_erofs_alloc_pcluster fs/erofs/zdata.c:262 [inline]
z_erofs_register_pcluster fs/erofs/zdata.c:749 [inline]
z_erofs_pcluster_begin fs/erofs/zdata.c:840 [inline]
z_erofs_scan_folio+0x162e/0x4540 fs/erofs/zdata.c:1056
z_erofs_readahead+0x672/0xb40 fs/erofs/zdata.c:1922
read_pages+0x177/0x580 mm/readahead.c:160
page_cache_ra_unbounded+0x63b/0x740 mm/readahead.c:297
page_cache_sync_readahead include/linux/pagemap.h:1369 [inline]
erofs_readdir+0x567/0x1020 fs/erofs/dir.c:77
iterate_dir+0x3a2/0x580 fs/readdir.c:108
__do_sys_getdents fs/readdir.c:326 [inline]
__se_sys_getdents+0xe4/0x250 fs/readdir.c:312
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5917 tgid 5917 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1395 [inline]
__free_frozen_pages+0xb59/0xce0 mm/page_alloc.c:2895
vfree+0x2ad/0x470 mm/vmalloc.c:3434
kcov_put kernel/kcov.c:439 [inline]
kcov_close+0x2e/0x60 kernel/kcov.c:535
__fput+0x45b/0xa80 fs/file_table.c:468
task_work_run+0x1d4/0x260 kernel/task_work.c:227
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x6b5/0x2300 kernel/exit.c:961
do_group_exit+0x21c/0x2d0 kernel/exit.c:1102
get_signal+0x125e/0x1310 kernel/signal.c:3034
arch_do_signal_or_restart+0x9a/0x750 arch/x86/kernel/signal.c:337
exit_to_user_mode_loop+0x75/0x110 kernel/entry/common.c:40
exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline]
do_syscall_64+0x2bd/0x3b0 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff888056560880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888056560900: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
>ffff888056560980: fc fc fc fc fc fc fc fc fc fc fc 00 00 00 00 00
^
ffff888056560a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888056560a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
Tested on:
commit: 6debb690 Merge tag 'drm-fixes-2025-08-23-1' of https:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=111d8062580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
patch: https://syzkaller.appspot.com/x/patch.diff?x=14ce8c42580000
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
2025-08-22 19:46 ` syzbot
2025-08-23 0:53 ` Edward Adam Davis
@ 2025-08-23 1:22 ` Edward Adam Davis
2025-08-23 1:53 ` syzbot
2025-08-23 1:53 ` [PATCH] erofs: Prohibit access to excessive algorithmformat Edward Adam Davis
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Edward Adam Davis @ 2025-08-23 1:22 UTC (permalink / raw)
To: syzbot+5a398eb460ddaa6f242f; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 2d73297003d2..085fa0685a57 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -762,6 +762,10 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
pcl->from_meta = map->m_flags & EROFS_MAP_META;
fe->mode = Z_EROFS_PCLUSTER_FOLLOWED;
+ if (pcl->algorithmformat >= Z_EROFS_COMPRESSION_MAX) {
+ err = -EINVAL;
+ goto out;
+ }
/*
* lock all primary followed works before visible to others
* and mutex_trylock *never* fails for a new pcluster.
@@ -796,6 +800,7 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
err_out:
mutex_unlock(&pcl->lock);
+out:
z_erofs_free_pcluster(pcl);
return err;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-23 1:22 ` Edward Adam Davis
@ 2025-08-23 1:53 ` syzbot
0 siblings, 0 replies; 12+ messages in thread
From: syzbot @ 2025-08-23 1:53 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested on:
commit: 6debb690 Merge tag 'drm-fixes-2025-08-23-1' of https:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16f38062580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
patch: https://syzkaller.appspot.com/x/patch.diff?x=10fe8c42580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] erofs: Prohibit access to excessive algorithmformat
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
` (2 preceding siblings ...)
2025-08-23 1:22 ` Edward Adam Davis
@ 2025-08-23 1:53 ` Edward Adam Davis
2025-08-23 9:40 ` Gao Xiang
2025-08-23 9:37 ` [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue Gao Xiang
2025-08-25 8:30 ` Gao Xiang
5 siblings, 1 reply; 12+ messages in thread
From: Edward Adam Davis @ 2025-08-23 1:53 UTC (permalink / raw)
To: syzbot+5a398eb460ddaa6f242f
Cc: chao, dhavale, jefflexu, lihongbo22, linux-erofs, linux-kernel,
syzkaller-bugs, xiang, zbestahu
syz reported a global-out-of-bounds Read in z_erofs_decompress_queue.
OOB occurs in z_erofs_decompress_queue() because algorithmformat is too
large.
Added relevant checks when registering pcluster.
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
Tested-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/erofs/zdata.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 2d73297003d2..085fa0685a57 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -762,6 +762,10 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
pcl->from_meta = map->m_flags & EROFS_MAP_META;
fe->mode = Z_EROFS_PCLUSTER_FOLLOWED;
+ if (pcl->algorithmformat >= Z_EROFS_COMPRESSION_MAX) {
+ err = -EINVAL;
+ goto out;
+ }
/*
* lock all primary followed works before visible to others
* and mutex_trylock *never* fails for a new pcluster.
@@ -796,6 +800,7 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
err_out:
mutex_unlock(&pcl->lock);
+out:
z_erofs_free_pcluster(pcl);
return err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
` (3 preceding siblings ...)
2025-08-23 1:53 ` [PATCH] erofs: Prohibit access to excessive algorithmformat Edward Adam Davis
@ 2025-08-23 9:37 ` Gao Xiang
2025-08-23 10:07 ` syzbot
2025-08-25 8:30 ` Gao Xiang
5 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2025-08-23 9:37 UTC (permalink / raw)
To: syzbot, linux-erofs, linux-kernel, syzkaller-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] erofs: Prohibit access to excessive algorithmformat
2025-08-23 1:53 ` [PATCH] erofs: Prohibit access to excessive algorithmformat Edward Adam Davis
@ 2025-08-23 9:40 ` Gao Xiang
0 siblings, 0 replies; 12+ messages in thread
From: Gao Xiang @ 2025-08-23 9:40 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+5a398eb460ddaa6f242f
Cc: linux-kernel, syzkaller-bugs
Hi,
On 2025/8/23 09:53, Edward Adam Davis wrote:
> syz reported a global-out-of-bounds Read in z_erofs_decompress_queue.
>
> OOB occurs in z_erofs_decompress_queue() because algorithmformat is too
> large.
>
> Added relevant checks when registering pcluster.
>
> Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
> Tested-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Your analysis is correct, but the fix should be applied to zmap.c
instead since it parses the on-disk map format. Also, it's actually
a regression out of new encoded extents since the old compress
indexes already has the check.
I've submitted a formal fix:
https://lore.kernel.org/r/20250823093018.3117864-1-hsiangkao@linux.alibaba.com
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-23 9:37 ` [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue Gao Xiang
@ 2025-08-23 10:07 ` syzbot
0 siblings, 0 replies; 12+ messages in thread
From: syzbot @ 2025-08-23 10:07 UTC (permalink / raw)
To: hsiangkao, linux-erofs, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested on:
commit: e64b452f erofs: fix invalid algorithm for encoded exte..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
console output: https://syzkaller.appspot.com/x/log.txt?x=13f26a34580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
` (4 preceding siblings ...)
2025-08-23 9:37 ` [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue Gao Xiang
@ 2025-08-25 8:30 ` Gao Xiang
2025-08-25 10:57 ` syzbot
5 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2025-08-25 8:30 UTC (permalink / raw)
To: syzbot, linux-erofs, linux-kernel, syzkaller-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue
2025-08-25 8:30 ` Gao Xiang
@ 2025-08-25 10:57 ` syzbot
0 siblings, 0 replies; 12+ messages in thread
From: syzbot @ 2025-08-25 10:57 UTC (permalink / raw)
To: hsiangkao, linux-erofs, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested-by: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Tested on:
commit: 27ad5346 erofs: fix invalid algorithm for encoded exte..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
console output: https://syzkaller.appspot.com/x/log.txt?x=1506ec42580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e1e1566c7726877e
dashboard link: https://syzkaller.appspot.com/bug?extid=5a398eb460ddaa6f242f
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-08-25 10:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 18:55 [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue syzbot
2025-08-22 19:46 ` syzbot
2025-08-23 0:53 ` Edward Adam Davis
2025-08-23 1:09 ` syzbot
2025-08-23 1:22 ` Edward Adam Davis
2025-08-23 1:53 ` syzbot
2025-08-23 1:53 ` [PATCH] erofs: Prohibit access to excessive algorithmformat Edward Adam Davis
2025-08-23 9:40 ` Gao Xiang
2025-08-23 9:37 ` [syzbot] [erofs?] KASAN: global-out-of-bounds Read in z_erofs_decompress_queue Gao Xiang
2025-08-23 10:07 ` syzbot
2025-08-25 8:30 ` Gao Xiang
2025-08-25 10:57 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).