From: Heming Zhao <heming.zhao@suse.com>
To: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] ocfs2: validate suballoc slot of extent blocks
Date: Mon, 31 Aug 2026 22:04:57 +0800 [thread overview]
Message-ID: <apWJ8Jr9YSC03zqr@p15> (raw)
In-Reply-To: <20260831062848.2743436-5-joseph.qi@linux.alibaba.com>
On Mon, Aug 31, 2026 at 02:28:48PM +0800, Joseph Qi wrote:
> ocfs2_validate_extent_block() does not validate h_suballoc_slot against
> the mounted filesystem's slot range. Since extent blocks are allocated
> from a per-slot suballocator at runtime, their suballoc slot must be
> within range.
>
> Otherwise a corrupted image can carry an out-of-range slot. When the
> extent block is freed, ocfs2_cache_extent_block_free() caches it and
> ocfs2_free_cached_blocks() later passes the unvalidated slot to
> ocfs2_get_system_file_inode(), so get_local_system_inode() will either
> hit BUG_ON(slot == OCFS2_INVALID_SLOT) or compute an out-of-bounds
> index into the local_system_inodes array.
>
> Reject out-of-range suballoc slots during validation.
>
> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
LGTM.
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
> ---
> fs/ocfs2/alloc.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index be09e766ac1f..2abd242a438f 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -925,6 +925,20 @@ static int ocfs2_validate_extent_block(struct super_block *sb,
> goto bail;
> }
>
> + /*
> + * Extent blocks are allocated from a per-slot suballocator, so the
> + * slot must be in range. Otherwise freeing the block passes it to
> + * get_local_system_inode(), which hits BUG_ON() for
> + * OCFS2_INVALID_SLOT or computes an out-of-bounds index otherwise.
> + */
> + if ((u32)le16_to_cpu(eb->h_suballoc_slot) >= OCFS2_SB(sb)->max_slots) {
> + rc = ocfs2_error(sb,
> + "Extent block #%llu has an invalid h_suballoc_slot of %u\n",
> + (unsigned long long)bh->b_blocknr,
> + le16_to_cpu(eb->h_suballoc_slot));
> + goto bail;
> + }
> +
> if (le16_to_cpu(eb->h_list.l_count) != ocfs2_extent_recs_per_eb(sb)) {
> rc = ocfs2_error(sb,
> "Extent block #%llu has invalid l_count %u (expected %u)\n",
> --
> 2.39.3
>
prev parent reply other threads:[~2026-08-31 14:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 6:28 [PATCH 0/4] ocfs2: validate suballoc slot and bit of metadata blocks Joseph Qi
2026-08-31 6:28 ` [PATCH 1/4] ocfs2: restrict OCFS2_INVALID_SLOT suballoc slot to system inodes Joseph Qi
2026-08-31 14:02 ` Heming Zhao
2026-09-01 1:08 ` Joseph Qi
2026-09-01 1:16 ` Heming Zhao
2026-09-01 2:08 ` Joseph Qi
2026-08-31 6:28 ` [PATCH 2/4] ocfs2: validate suballoc bit during inode read Joseph Qi
2026-08-31 14:03 ` Heming Zhao
2026-08-31 6:28 ` [PATCH 3/4] ocfs2: validate suballoc slot of xattr and dir index blocks Joseph Qi
2026-08-31 14:04 ` Heming Zhao
2026-08-31 6:28 ` [PATCH 4/4] ocfs2: validate suballoc slot of extent blocks Joseph Qi
2026-08-31 14:04 ` Heming Zhao [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=apWJ8Jr9YSC03zqr@p15 \
--to=heming.zhao@suse.com \
--cc=akpm@linux-foundation.org \
--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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.