From: Greg KH <gregkh@linuxfoundation.org>
To: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Cc: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
linux-kernel@vger.kernel.org, ocfs2-devel@lists.linux.dev,
stable@vger.kernel.org
Subject: Re: [PATCH] ocfs2: fix potential OOB access in ocfs2_adjust_adjacent_records()
Date: Mon, 19 Jan 2026 07:37:17 +0100 [thread overview]
Message-ID: <2026011911-baboon-gazing-3e15@gregkh> (raw)
In-Reply-To: <20260118192318.44212-1-jiashengjiangcool@gmail.com>
On Sun, Jan 18, 2026 at 07:23:18PM +0000, Jiasheng Jiang wrote:
> In ocfs2_adjust_adjacent_records(), the code dereferences
> right_child_el->l_recs[0] without verifying that the extent list
> actually contains any records.
>
> If right_child_el->l_next_free_rec is 0 (e.g., due to a corrupted
> filesystem image), this results in an out-of-bounds access when
> accessing l_recs[0].e_cpos.
>
> In contrast, ocfs2_adjust_rightmost_records() explicitly validates
> that l_next_free_rec is non-zero before accessing records.
>
> This patch adds a check to ensure l_next_free_rec is not zero before
> proceeding. If the list is empty, we log an error and return to avoid
> reading invalid data.
>
> Fixes: dcd0538ff4e8 ("ocfs2: sparse b-tree support")
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
> ---
> fs/ocfs2/alloc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 58bf58b68955..bc6f26613e6e 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -1974,6 +1974,11 @@ static void ocfs2_adjust_adjacent_records(struct ocfs2_extent_rec *left_rec,
> {
> u32 left_clusters, right_end;
>
> + if (le16_to_cpu(right_child_el->l_next_free_rec) == 0) {
> + mlog(ML_ERROR, "Extent list has no records\n");
> + return;
> + }
> +
> /*
> * Interior nodes never have holes. Their cpos is the cpos of
> * the leftmost record in their child list. Their cluster
> --
> 2.25.1
>
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
prev parent reply other threads:[~2026-01-19 6:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 19:23 Jiasheng Jiang
2026-01-19 6:37 ` Greg KH [this message]
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=2026011911-baboon-gazing-3e15@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jiashengjiangcool@gmail.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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®