[lvc-project] [PATCH] ocfs2: add directory size check to ocfs2_find_dir_space_id()

Heming Zhao heming.zhao at suse.com
Fri Oct 17 01:21:29 MSK 2025


On 10/13/25 18:37, Dmitry Antipov wrote:
> In 'ocfs2_find_dir_space_id()', add extra check whether the directory
> data block is large enough to hold at least one directory entry, and
> raise 'ocfs2_error()' if the former is unexpectedly small.
> 
> Reported-by: syzbot+ded9116588a7b73c34bc at syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ded9116588a7b73c34bc
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>

Reviewed-by: Heming Zhao <heming.zhao at suse.com>> ---
>   fs/ocfs2/dir.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index b9bf1428a3d9..3c2dacba9b0a 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -3444,6 +3444,14 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
>   		offset += le16_to_cpu(de->rec_len);
>   	}
>   
> +	if (!last_de) {
> +		ret = ocfs2_error(sb, "Directory entry (#%llu: size=%lld) "
> +				  "is unexpectedly short",
> +				  (unsigned long long)OCFS2_I(dir)->ip_blkno,
> +				  i_size_read(dir));
> +		goto out;
> +	}
> +
>   	/*
>   	 * We're going to require expansion of the directory - figure
>   	 * out how many blocks we'll need so that a place for the




More information about the lvc-project mailing list