From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: ZhengYuan Huang <gality369@gmail.com>
Cc: mark@fasheh.com, jlbec@evilplan.org, ocfs2-devel@lists.linux.dev,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
r33s3n6@gmail.com, zzzccc427@gmail.com, tom442288@tuta.io,
Heming Zhao <heming.zhao@suse.com>
Subject: Re: [PATCH v2] ocfs2: validate global bitmap cl_bpc before resize
Date: Wed, 5 Aug 2026 19:54:17 +0800 [thread overview]
Message-ID: <a7f2e697-ee2b-4548-a16d-ce9a10bde14b@linux.alibaba.com> (raw)
In-Reply-To: <20260804064445.766072-1-gality369@gmail.com>
On 8/4/26 2:44 PM, ZhengYuan Huang wrote:
> [BUG]
> A corrupted global bitmap inode can make online group extension scan past
> the end of a group descriptor bitmap:
>
> BUG: KASAN: use-after-free in _find_next_bit+0xef/0x120 lib/find_bit.c:157
> Read of size 8 at addr ffff888021b52000 by task syz.0.34/409
> Call Trace:
> ...
> _find_next_bit+0xef/0x120 lib/find_bit.c:157
> find_next_bit include/linux/find.h:73 [inline]
> find_next_bit_le include/linux/find.h:518 [inline]
> ocfs2_find_max_contig_free_bits+0x53/0xb0 fs/ocfs2/suballoc.c:1292
> ocfs2_update_last_group_and_inode fs/ocfs2/resize.c:127 [inline]
> ocfs2_group_extend+0x83e/0x1ae0 fs/ocfs2/resize.c:350
> ocfs2_ioctl+0x175/0x6e0 fs/ocfs2/ioctl.c:869
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:597 [inline]
> __se_sys_ioctl fs/ioctl.c:583 [inline]
> __x64_sys_ioctl+0x197/0x1e0 fs/ioctl.c:583
> ...
>
> [CAUSE]
> ocfs2_group_extend() consumes the global bitmap dinode's cl_bpc value in
> resize arithmetic. The existing inode validation checked cl_bpc only for
> non-global chain allocators, so a corrupted global bitmap value could reach
> the resize path. With cl_bpc changed from 1 to 51457, extending by seven
> clusters wraps the u16 bit count and grows a 2048-bit group to 34567 bits,
> exceeding its 32256-bit bitmap capacity.
>
> [FIX]
> Validate cl_bpc in ocfs2_validate_inode_block() for every chain allocator,
> including the global bitmap, against the value derived from the
> filesystem's cluster and block sizes. This rejects the corrupted dinode
> when it is read and removes the resize-local check that incorrectly assumed
> cl_bpc is always one. The resize path still uses the validated value for
> its arithmetic.
It seems a stale message here.
Thanks,
Joseph
>
> Fixes: d659072f7368 ("[PATCH 1/2] ocfs2: Add group extend for online resize")
> Signed-off-by: ZhengYuan Huang <gality369@gmail.com>
> ---
> v2:
> - Derive the expected cl_bpc from the filesystem block and cluster sizes.
> - Extend the existing inode-block validation to cover the global bitmap.
> - Remove the resize-local hardcoded cl_bpc check.
> ---
> ---
> fs/ocfs2/inode.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
> index 41db7dd39ed9..0e1f9ae0eb73 100644
> --- a/fs/ocfs2/inode.c
> +++ b/fs/ocfs2/inode.c
> @@ -1683,12 +1683,11 @@ int ocfs2_validate_inode_block(struct super_block *sb,
> le16_to_cpu(cl->cl_next_free_rec));
> goto bail;
> }
> - if (OCFS2_SB(sb)->bitmap_blkno &&
> - OCFS2_SB(sb)->bitmap_blkno != le64_to_cpu(di->i_blkno) &&
> - le16_to_cpu(cl->cl_bpc) != bpc) {
> - rc = ocfs2_error(sb, "Invalid dinode %llu: bits per cluster %u\n",
> + if (le16_to_cpu(cl->cl_bpc) != bpc) {
> + rc = ocfs2_error(sb,
> + "Invalid dinode %llu: bits per cluster %u (expected %u)\n",
> (unsigned long long)bh->b_blocknr,
> - le16_to_cpu(cl->cl_bpc));
> + le16_to_cpu(cl->cl_bpc), bpc);
> goto bail;
> }
> }
prev parent reply other threads:[~2026-08-05 11:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 6:44 [PATCH v2] ocfs2: validate global bitmap cl_bpc before resize ZhengYuan Huang
2026-08-05 11:54 ` Joseph Qi [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=a7f2e697-ee2b-4548-a16d-ce9a10bde14b@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=baijiaju1990@gmail.com \
--cc=gality369@gmail.com \
--cc=heming.zhao@suse.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=r33s3n6@gmail.com \
--cc=tom442288@tuta.io \
--cc=zzzccc427@gmail.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