From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Vasiliy Kovalev <kovalev@altlinux.org>
Cc: jlbec@evilplan.org, kurt.hackel@oracle.com,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
mark@fasheh.com, ocfs2-devel@lists.linux.dev,
syzbot+66c146268dc88f4341fd@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] ocfs2: validate l_tree_depth to avoid out-of-bounds access
Date: Fri, 14 Feb 2025 16:32:56 +0800 [thread overview]
Message-ID: <bb8e95f6-ee91-47b9-82a0-86d576f67e39@linux.alibaba.com> (raw)
In-Reply-To: <20250214080038.735185-1-kovalev@altlinux.org>
On 2025/2/14 16:00, Vasiliy Kovalev wrote:
> The l_tree_depth field is 16-bit (__le16), but the actual
> maximum depth is limited to OCFS2_MAX_PATH_DEPTH.
>
> 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>
> ---
> v2: Restricted depth to OCFS2_MAX_PATH_DEPTH and moved the check
> to __ocfs2_find_path().
> ---
> fs/ocfs2/alloc.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 4414743b638e8..cec8fc5cb8e87 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -1803,6 +1803,14 @@ static int __ocfs2_find_path(struct ocfs2_caching_info *ci,
>
> el = root_el;
> while (el->l_tree_depth) {
> + if (unlikely(le16_to_cpu(el->l_tree_depth) > OCFS2_MAX_PATH_DEPTH)) {
More precisely, it's ">= OCFS2_MAX_PATH_DEPTH".
> + ocfs2_error(ocfs2_metadata_cache_get_super(ci),
> + "Owner %llu has invalid tree depth %u in extent list\n",
> + (unsigned long long)ocfs2_metadata_cache_owner(ci),
> + le16_to_cpu(el->l_tree_depth));
> + ret = -EROFS;
> + goto out;
> + }
> if (le16_to_cpu(el->l_next_free_rec) == 0) {
> ocfs2_error(ocfs2_metadata_cache_get_super(ci),
> "Owner %llu has empty extent list at depth %u\n",
next prev parent reply other threads:[~2025-02-14 8:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 19:16 [PATCH] " Vasiliy Kovalev
2025-02-14 6:18 ` Joseph Qi
2025-02-14 8:00 ` [PATCH v2] " Vasiliy Kovalev
2025-02-14 8:32 ` Joseph Qi [this message]
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=bb8e95f6-ee91-47b9-82a0-86d576f67e39@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=jlbec@evilplan.org \
--cc=kovalev@altlinux.org \
--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®