Re: [PATCH] ocfs2: validate quota file block count in ocfs2_local_read_info()

From: Joseph Qi

Date: Wed Jul 01 2026 - 05:14:39 EST




On 6/25/26 4:44 PM, Dmitry Antipov wrote:
> In 'ocfs2_local_read_info()', assume that number of blocks allocated
> for local quota file should not exceed the limit based on claimed
> number of chunks, and refuse an attempt to enable quota otherwise.
>
> Reported-by: Sam Sun <samsun1006219@xxxxxxxxx>
> Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
> ---
> fs/ocfs2/quota_local.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
> index f55810c59b1b..33a9b5b449c8 100644
> --- a/fs/ocfs2/quota_local.c
> +++ b/fs/ocfs2/quota_local.c
> @@ -733,6 +733,13 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)
> oinfo->dqi_blocks = le32_to_cpu(ldinfo->dqi_blocks);
> oinfo->dqi_libh = bh;
>
> + if (oinfo->dqi_blocks > oinfo->dqi_chunks * ol_chunk_blocks(sb)) {

This will reject valid on-disk layouts.
See ol_quota_chunk_block().

BTW, could we move the geometry bound check into a dedicated info-block
validator?

Thanks,
Joseph

> + mlog(ML_ERROR, "unexpectedly large local quota "
> + "file block count %u\n", oinfo->dqi_blocks);
> + status = -EFSCORRUPTED;
> + goto out_err;
> + }
> +
> /* We crashed when using local quota file? */
> if (!(oinfo->dqi_flags & OLQF_CLEAN)) {
> rec = OCFS2_SB(sb)->quota_rec;