From: Vasiliy Kovalev <kovalev@altlinux.org>
To: linux-kernel@vger.kernel.org, ocfs2-devel@lists.linux.dev,
Kurt Hackel <kurt.hackel@oracle.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
Joel Becker <jlbec@evilplan.org>, Mark Fasheh <mark@fasheh.com>
Cc: kovalev@altlinux.org, lvc-project@linuxtesting.org,
syzbot+66c146268dc88f4341fd@syzkaller.appspotmail.com
Subject: [PATCH] ocfs2: validate l_tree_depth to avoid out-of-bounds access
Date: Thu, 13 Feb 2025 22:16:42 +0300 [thread overview]
Message-ID: <20250213191642.720812-1-kovalev@altlinux.org> (raw)
The l_tree_depth field in struct ocfs2_extent_list is defined
as __le16, but according to the comments in the structure
definition, the high 8 bits must not be used, meaning its
maximum valid value is 255.
Add a check to prevent out-of-bounds access if l_tree_depth
has an invalid value, which may occur when reading from a
corrupted mounted disk [1].
Fixes: ccd979bdbce9 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Reported-by: syzbot+66c146268dc88f4341fd@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=66c146268dc88f4341fd [1]
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
fs/ocfs2/extent_map.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index 930150ed5db15..0d9c25fdec029 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -415,6 +415,15 @@ static int ocfs2_get_clusters_nocache(struct inode *inode,
tree_height = le16_to_cpu(el->l_tree_depth);
if (tree_height > 0) {
+ if (unlikely(tree_height > 255)) {
+ ocfs2_error(inode->i_sb,
+ "Inode %lu has too large l_tree_depth=%u in leaf block %llu\n",
+ inode->i_ino, tree_height,
+ (unsigned long long)di_bh->b_blocknr);
+ ret = -EROFS;
+ goto out;
+ }
+
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, v_cluster,
&eb_bh);
if (ret) {
--
2.42.2
next reply other threads:[~2025-02-13 19:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 19:16 Vasiliy Kovalev [this message]
2025-02-14 6:18 ` Joseph Qi
2025-02-14 8:00 ` [PATCH v2] " Vasiliy Kovalev
2025-02-14 8:32 ` Joseph Qi
2025-02-14 8:49 ` [PATCH v3] " Vasiliy Kovalev
2025-02-14 9:55 ` Joseph Qi
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=20250213191642.720812-1-kovalev@altlinux.org \
--to=kovalev@altlinux.org \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=kurt.hackel@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=syzbot+66c146268dc88f4341fd@syzkaller.appspotmail.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®