[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <nvaagj2qdkgifr7lwyzybwyvfvuwmxunpjinklepvtyoi5v6tw@vsihwyqiu2i4>
Date: Mon, 19 Jan 2026 22:50:00 +0800
From: Heming Zhao <heming.zhao@...e.com>
To: Jiasheng Jiang <jiashengjiangcool@...il.com>
Cc: Mark Fasheh <mark@...heh.com>, Joel Becker <jlbec@...lplan.org>,
Joseph Qi <joseph.qi@...ux.alibaba.com>, linux-kernel@...r.kernel.org, ocfs2-devel@...ts.linux.dev
Subject: Re: [PATCH] ocfs2: fix slab-out-of-bounds in
ocfs2_rotate_requires_path_adjustment
On Fri, Jan 16, 2026 at 05:21:13PM +0000, Jiasheng Jiang wrote:
> In ocfs2_rotate_requires_path_adjustment(), the variable 'next_free' is
> assigned the value of 'left_el->l_next_free_rec'. This value is then used
> to index the 'l_recs' array as 'next_free - 1'.
>
> If the filesystem is corrupted or in an unexpected state such that
> 'l_next_free_rec' is 0, this leads to an array index of -1, triggering
> a slab-out-of-bounds access.
>
> Other functions in alloc.c, such as ocfs2_rotate_leaf() and
> ocfs2_update_edge_lengths(), effectively guard against this condition.
> This patch adds a similar check to return 0 immediately if 'next_free'
> is 0, preventing the out-of-bounds access.
Do you have reproduction steps to support your analysis?
- Heming
>
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>
> ---
> fs/ocfs2/alloc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 58bf58b68955..b15c6f751d99 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -2327,6 +2327,10 @@ static int ocfs2_rotate_requires_path_adjustment(struct ocfs2_path *left_path,
>
> left_el = path_leaf_el(left_path);
> next_free = le16_to_cpu(left_el->l_next_free_rec);
> +
> + if (unlikely(next_free == 0))
> + return 0;
> +
> rec = &left_el->l_recs[next_free - 1];
>
> if (insert_cpos > le32_to_cpu(rec->e_cpos))
> --
> 2.25.1
>
>
Powered by blists - more mailing lists