From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com
Cc: chao@kernel.org, dhavale@google.com, jefflexu@linux.alibaba.com,
lihongbo22@huawei.com, linux-erofs@lists.ozlabs.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
xiang@kernel.org, zbestahu@gmail.com
Subject: [PATCH] erofs: Prohibit access to excessive algorithmformat
Date: Sat, 23 Aug 2025 09:53:37 +0800 [thread overview]
Message-ID: <tencent_FC33559E331B7F4BA91BB62522BA1CBB8C08@qq.com> (raw)
In-Reply-To: <68a8bd20.050a0220.37038e.005a.GAE@google.com>
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
next prev parent reply other threads:[~2025-08-23 1:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Edward Adam Davis [this message]
2025-08-23 9:40 ` [PATCH] erofs: Prohibit access to excessive algorithmformat 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_FC33559E331B7F4BA91BB62522BA1CBB8C08@qq.com \
--to=eadavis@qq.com \
--cc=chao@kernel.org \
--cc=dhavale@google.com \
--cc=jefflexu@linux.alibaba.com \
--cc=lihongbo22@huawei.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+5a398eb460ddaa6f242f@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=xiang@kernel.org \
--cc=zbestahu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®