diff mbox series

[nfs-utils] mount: reject "namlen=" option for a NFSv4 mount

Message ID 20240322103618.1270-1-chenhx.fnst@fujitsu.com (mailing list archive)
State New
Headers show
Series [nfs-utils] mount: reject "namlen=" option for a NFSv4 mount | expand

Commit Message

Chen Hanxiao March 22, 2024, 10:36 a.m. UTC
namlen is not a valid option for NFSv4.
Currently, we could pass a namlen=xxx in a NFSv4 mount,
the mount command succeed and namlen is ignored silently

# mount -o vers=4,namlen=100 192.168.122.19:/nfsroot /mnt/ -vvv
mount.nfs: timeout set for Fri Mar 22 14:22:18 2024
mount.nfs: trying text-based options 'namlen=100,vers=4.2,
	   addr=192.168.122.19,clientaddr=192.168.122.15'

This patch reject "namlen=" option in a NFSv4 mount.

Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
---
 utils/mount/stropts.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Steve Dickson April 2, 2024, 4:20 p.m. UTC | #1
Hello,

On 3/22/24 6:36 AM, Chen Hanxiao wrote:
> namlen is not a valid option for NFSv4.
> Currently, we could pass a namlen=xxx in a NFSv4 mount,
> the mount command succeed and namlen is ignored silently
I'm not sure it makes senses to fail a mount for
a parameter  that is ignored. Maybe throw a warning
that the par is being ignored...

What problem did this patch solve for you?

steved.

> 
> # mount -o vers=4,namlen=100 192.168.122.19:/nfsroot /mnt/ -vvv
> mount.nfs: timeout set for Fri Mar 22 14:22:18 2024
> mount.nfs: trying text-based options 'namlen=100,vers=4.2,
> 	   addr=192.168.122.19,clientaddr=192.168.122.15'
> 
> This patch reject "namlen=" option in a NFSv4 mount.
> 
> Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
> ---
>   utils/mount/stropts.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
> index dbdd11e7..028ff6a6 100644
> --- a/utils/mount/stropts.c
> +++ b/utils/mount/stropts.c
> @@ -780,6 +780,15 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
>   		goto out_fail;
>   	}
>   
> +	if (po_contains(options, "namlen")) {
> +		if (verbose) {
> +			printf(_("%s: Unsupported nfs4 mount option(s) passed '%s'\n"),
> +				progname, *mi->extra_opts);
> +		}
> +		errno = EINVAL;
> +		goto out_fail;
> +	}
> +
>   	if (mi->version.v_mode != V_SPECIFIC) {
>   		char *fmt;
>   		switch (mi->version.minor) {
Chen Hanxiao April 3, 2024, 3:13 a.m. UTC | #2
> -----邮件原件-----
> 发件人: Steve Dickson <steved@redhat.com>
> 发送时间: 2024年4月3日 0:21
> 收件人: Chen, Hanxiao <chenhx.fnst@fujitsu.com>
> 抄送: linux-nfs@vger.kernel.org
> 主题: Re: [nfs-utils PATCH] mount: reject "namlen=" option for a NFSv4 mount
> 
> Hello,
> 
> On 3/22/24 6:36 AM, Chen Hanxiao wrote:
> > namlen is not a valid option for NFSv4
> > Currently, we could pass a namlen=xxx in a NFSv4 mount,
> > the mount command succeed and namlen is ignored silently
> I'm not sure it makes senses to fail a mount for
> a parameter  that is ignored. Maybe throw a warning
> that the par is being ignored...
> 
> What problem did this patch solve for you?
> 

When I do mount tests with namelen, I'm confused about the results the test:
	Parameter namlen= was ignored silently without sloppy option.

When digging into kernel source, I found that we don't need namlen for NFSv4 at all.
So, I think we'd better give user some feed back.

Throw a warning is much better than failing a mount.

Thanks for your advice.

Regards,
- Chen
diff mbox series

Patch

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index dbdd11e7..028ff6a6 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -780,6 +780,15 @@  static int nfs_do_mount_v4(struct nfsmount_info *mi,
 		goto out_fail;
 	}
 
+	if (po_contains(options, "namlen")) {
+		if (verbose) {
+			printf(_("%s: Unsupported nfs4 mount option(s) passed '%s'\n"),
+				progname, *mi->extra_opts);
+		}
+		errno = EINVAL;
+		goto out_fail;
+	}
+
 	if (mi->version.v_mode != V_SPECIFIC) {
 		char *fmt;
 		switch (mi->version.minor) {