[lvc-project] [PATCH v2] ocfs2: add chain list sanity check to ocfs2_block_group_alloc()

Heming Zhao heming.zhao at suse.com
Thu Oct 16 14:30:07 MSK 2025


On 10/16/25 16:46, Dmitry Antipov wrote:
> In 'ocfs2_block_group_alloc()', add an extra check whether the maximum
> amount of chain records in 'struct ocfs2_chain_list' matches the value
> calculated based on the filesystem block size.
> 
> Reported-by: syzbot+77026564530dbc29b854 at syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=77026564530dbc29b854
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>

LGTM
Reviewed-by: Heming Zhao <heming.zhao at suse.com>> ---
> v2: remove redundant call to mlog_errno() and comment (Heming Zhao)
> ---
>   fs/ocfs2/suballoc.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
> index 6ac4dcd54588..e6d4f5015f84 100644
> --- a/fs/ocfs2/suballoc.c
> +++ b/fs/ocfs2/suballoc.c
> @@ -671,6 +671,11 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
>   	BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));
>   
>   	cl = &fe->id2.i_chain;
> +	if (le16_to_cpu(cl->cl_count) != ocfs2_chain_recs_per_inode(osb->sb)) {
> +		status = -EINVAL;
> +		goto bail;
> +	}
> +
>   	status = ocfs2_reserve_clusters_with_limit(osb,
>   						   le16_to_cpu(cl->cl_cpg),
>   						   max_block, flags, &ac);




More information about the lvc-project mailing list