[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3rscuc2wkxmfwgvyblxqlormqecmqtbysh6pploetnd2pendlh@xoiinaf7j6aj>
Date: Mon, 3 Nov 2025 12:39:40 +0100
From: Jan Kara <jack@...e.cz>
To: Fedor Pchelkin <pchelkin@...ras.ru>
Cc: Theodore Ts'o <tytso@....edu>, Jan Kara <jack@...e.cz>,
linux-ext4@...r.kernel.org, Andreas Dilger <adilger.kernel@...ger.ca>,
"Darrick J. Wong" <djwong@...nel.org>, linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH v2 2/2] ext4: check if mount_opts is NUL-terminated in
ext4_ioctl_set_tune_sb()
On Sat 01-11-25 19:04:29, Fedor Pchelkin wrote:
> params.mount_opts may come as potentially non-NUL-term string. Userspace
> is expected to pass a NUL-term string. Add an extra check to ensure this
> holds true. Note that further code utilizes strscpy_pad() so this is just
> for proper informing the user of incorrect data being provided.
>
> Found by Linux Verification Center (linuxtesting.org).
>
> Signed-off-by: Fedor Pchelkin <pchelkin@...ras.ru>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
>
> v2: check length of mount_opts in superblock tuning ioctl (Jan Kara)
>
> Can't plainly return error at strscpy_pad() call site in
> ext4_sb_setparams(), that's a void ext4_update_sb_callback.
>
> v1: https://lore.kernel.org/lkml/20251028130949.599847-1-pchelkin@ispras.ru/T/#u
>
> fs/ext4/ioctl.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index a93a7baae990..3dec26c939fd 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp,
> if (copy_from_user(¶ms, in, sizeof(params)))
> return -EFAULT;
>
> + if (strnlen(params.mount_opts, sizeof(params.mount_opts)) ==
> + sizeof(params.mount_opts))
> + return -E2BIG;
> +
> if ((params.set_flags & ~TUNE_OPS_SUPPORTED) != 0)
> return -EOPNOTSUPP;
>
> --
> 2.51.0
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists