mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>
Cc: Theodore Ts'o <tytso@mit.edu>, <linux-ext4@vger.kernel.org>,
	Jan Kara <jack@suse.cz>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	"Darrick J. Wong" <djwong@kernel.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: Re: [PATCH v2 2/2] ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb()
Date: Sat, 8 Nov 2025 12:05:45 +0800	[thread overview]
Message-ID: <d4e265dd-a4c0-4e06-995e-98602275100c@huawei.com> (raw)
In-Reply-To: <20251101160430.222297-2-pchelkin@ispras.ru>

On 2025-11-02 00:04, 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@ispras.ru>

Looks good to me.

Reviewed-by: Baokun Li <libaokun1@huawei.com>

> ---
>
> 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(&params, 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;
>  



  parent reply	other threads:[~2025-11-08  4:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-01 16:04 [PATCH v2 1/2] ext4: fix string copying in parse_apply_sb_mount_options() Fedor Pchelkin
2025-11-01 16:04 ` [PATCH v2 2/2] ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb() Fedor Pchelkin
2025-11-03 11:39   ` Jan Kara
2025-11-08  4:05   ` Baokun Li [this message]
2025-11-03 11:38 ` [PATCH v2 1/2] ext4: fix string copying in parse_apply_sb_mount_options() Jan Kara
2025-11-08  4:04 ` Baokun Li
2025-11-17 19:13 ` Theodore Ts'o

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=d4e265dd-a4c0-4e06-995e-98602275100c@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=djwong@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=pchelkin@ispras.ru \
    --cc=tytso@mit.edu \
    /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

all inboxes | Powered by JetHome®