All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Give containers a unique client id
@ 2020-10-07 21:07 trondmy
  2020-10-07 21:07 ` [PATCH 1/2] NFSv4: Clean up initialisation of uniquified client id strings trondmy
  0 siblings, 1 reply; 10+ messages in thread
From: trondmy @ 2020-10-07 21:07 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

This series adds the missing patches to allow a container to set a
unique client id using /sys/fs/nfs/net/nfs_client/identifier, and
have NFS use that for any new NFS mounts that are initiated by that
container.

Trond Myklebust (2):
  NFSv4: Clean up initialisation of uniquified client id strings
  NFSv4: Use the net namespace uniquifier if it is set

 fs/nfs/nfs4proc.c | 90 ++++++++++++++++++++++++++---------------------
 1 file changed, 49 insertions(+), 41 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] NFSv4: Clean up initialisation of uniquified client id strings
  2020-10-07 21:07 [PATCH 0/2] Give containers a unique client id trondmy
@ 2020-10-07 21:07 ` trondmy
  2020-10-07 21:07   ` [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set trondmy
  0 siblings, 1 reply; 10+ messages in thread
From: trondmy @ 2020-10-07 21:07 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

When the user sets a uniquifier, then ensure we copy the string
so that calls to strlen() etc are atomic with calls to snprintf().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4proc.c | 73 +++++++++++++++++++++--------------------------
 1 file changed, 32 insertions(+), 41 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6e95c85fe395..3a39887e0e6e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6006,9 +6006,20 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
 	memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
 
+static size_t
+nfs4_get_uniquifier(char *buf, size_t buflen)
+{
+	buf[0] = '\0';
+	if (nfs4_client_id_uniquifier[0] != '\0')
+		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
+	return 0;
+}
+
 static int
 nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 {
+	char buf[NFS4_CLIENT_ID_UNIQ_LEN];
+	size_t buflen;
 	size_t len;
 	char *str;
 
@@ -6022,8 +6033,11 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 		strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) +
 		1;
 	rcu_read_unlock();
-	if (nfs4_client_id_uniquifier[0] != '\0')
-		len += strlen(nfs4_client_id_uniquifier) + 1;
+
+	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	if (buflen)
+		len += buflen + 1;
+
 	if (len > NFS4_OPAQUE_LIMIT + 1)
 		return -EINVAL;
 
@@ -6037,10 +6051,9 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 		return -ENOMEM;
 
 	rcu_read_lock();
-	if (nfs4_client_id_uniquifier[0] != '\0')
+	if (buflen)
 		scnprintf(str, len, "Linux NFSv4.0 %s/%s/%s",
-			  clp->cl_rpcclient->cl_nodename,
-			  nfs4_client_id_uniquifier,
+			  clp->cl_rpcclient->cl_nodename, buf,
 			  rpc_peeraddr2str(clp->cl_rpcclient,
 					   RPC_DISPLAY_ADDR));
 	else
@@ -6054,51 +6067,24 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 	return 0;
 }
 
-static int
-nfs4_init_uniquifier_client_string(struct nfs_client *clp)
-{
-	size_t len;
-	char *str;
-
-	len = 10 + 10 + 1 + 10 + 1 +
-		strlen(nfs4_client_id_uniquifier) + 1 +
-		strlen(clp->cl_rpcclient->cl_nodename) + 1;
-
-	if (len > NFS4_OPAQUE_LIMIT + 1)
-		return -EINVAL;
-
-	/*
-	 * Since this string is allocated at mount time, and held until the
-	 * nfs_client is destroyed, we can use GFP_KERNEL here w/o worrying
-	 * about a memory-reclaim deadlock.
-	 */
-	str = kmalloc(len, GFP_KERNEL);
-	if (!str)
-		return -ENOMEM;
-
-	scnprintf(str, len, "Linux NFSv%u.%u %s/%s",
-			clp->rpc_ops->version, clp->cl_minorversion,
-			nfs4_client_id_uniquifier,
-			clp->cl_rpcclient->cl_nodename);
-	clp->cl_owner_id = str;
-	return 0;
-}
-
 static int
 nfs4_init_uniform_client_string(struct nfs_client *clp)
 {
+	char buf[NFS4_CLIENT_ID_UNIQ_LEN];
+	size_t buflen;
 	size_t len;
 	char *str;
 
 	if (clp->cl_owner_id != NULL)
 		return 0;
 
-	if (nfs4_client_id_uniquifier[0] != '\0')
-		return nfs4_init_uniquifier_client_string(clp);
-
 	len = 10 + 10 + 1 + 10 + 1 +
 		strlen(clp->cl_rpcclient->cl_nodename) + 1;
 
+	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	if (buflen)
+		len += buflen + 1;
+
 	if (len > NFS4_OPAQUE_LIMIT + 1)
 		return -EINVAL;
 
@@ -6111,9 +6097,14 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
 	if (!str)
 		return -ENOMEM;
 
-	scnprintf(str, len, "Linux NFSv%u.%u %s",
-			clp->rpc_ops->version, clp->cl_minorversion,
-			clp->cl_rpcclient->cl_nodename);
+	if (buflen)
+		scnprintf(str, len, "Linux NFSv%u.%u %s/%s",
+			  clp->rpc_ops->version, clp->cl_minorversion,
+			  buf, clp->cl_rpcclient->cl_nodename);
+	else
+		scnprintf(str, len, "Linux NFSv%u.%u %s",
+			  clp->rpc_ops->version, clp->cl_minorversion,
+			  clp->cl_rpcclient->cl_nodename);
 	clp->cl_owner_id = str;
 	return 0;
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:07 ` [PATCH 1/2] NFSv4: Clean up initialisation of uniquified client id strings trondmy
@ 2020-10-07 21:07   ` trondmy
  2020-10-07 21:25     ` J. Bruce Fields
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: trondmy @ 2020-10-07 21:07 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

If a container sets a net namespace specific uniquifier, then use that
in the setclientid/exchangeid process.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4proc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 3a39887e0e6e..a1dd46e7440b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -63,6 +63,7 @@
 #include "callback.h"
 #include "pnfs.h"
 #include "netns.h"
+#include "sysfs.h"
 #include "nfs4idmap.h"
 #include "nfs4session.h"
 #include "fscache.h"
@@ -6007,9 +6008,25 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
 }
 
 static size_t
-nfs4_get_uniquifier(char *buf, size_t buflen)
+nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
 {
+	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
+	struct nfs_netns_client *nn_clp = nn->nfs_client;
+	const char *id;
+	size_t len;
+
 	buf[0] = '\0';
+
+	if (nn_clp) {
+		rcu_read_lock();
+		id = rcu_dereference(nn_clp->identifier);
+		if (id && *id != '\0')
+			len = strlcpy(buf, id, buflen);
+		rcu_read_unlock();
+		if (len)
+			return len;
+	}
+
 	if (nfs4_client_id_uniquifier[0] != '\0')
 		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
 	return 0;
@@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 		1;
 	rcu_read_unlock();
 
-	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
 	if (buflen)
 		len += buflen + 1;
 
@@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
 	len = 10 + 10 + 1 + 10 + 1 +
 		strlen(clp->cl_rpcclient->cl_nodename) + 1;
 
-	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
 	if (buflen)
 		len += buflen + 1;
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:07   ` [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set trondmy
@ 2020-10-07 21:25     ` J. Bruce Fields
  2020-10-07 21:34       ` Trond Myklebust
  2020-10-07 22:02     ` Dai Ngo
  2020-10-07 22:40       ` kernel test robot
  2 siblings, 1 reply; 10+ messages in thread
From: J. Bruce Fields @ 2020-10-07 21:25 UTC (permalink / raw)
  To: trondmy; +Cc: Anna Schumaker, linux-nfs

On Wed, Oct 07, 2020 at 05:07:20PM -0400, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> If a container sets a net namespace specific uniquifier,

What you're actually checking is if nn->nfs_client != NULL, and that's
pretty much always true.  (The only time it's NULL is an allocation
failure in some initialization code, I think.)

> +	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
> +	struct nfs_netns_client *nn_clp = nn->nfs_client;
> +	const char *id;
> +	size_t len;
> +
>  	buf[0] = '\0';
> +
> +	if (nn_clp) {

Are you sure you don't mean

	if (nn_clp->identifier)

?

I think that's how you tell if someone's set it.

--b.

> +		rcu_read_lock();
> +		id = rcu_dereference(nn_clp->identifier);
> +		if (id && *id != '\0')
> +			len = strlcpy(buf, id, buflen);
> +		rcu_read_unlock();
> +		if (len)
> +			return len;
> +	}
> +
>  	if (nfs4_client_id_uniquifier[0] != '\0')
>  		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
>  	return 0;
> @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
>  		1;
>  	rcu_read_unlock();
>  
> -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
>  	if (buflen)
>  		len += buflen + 1;
>  
> @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
>  	len = 10 + 10 + 1 + 10 + 1 +
>  		strlen(clp->cl_rpcclient->cl_nodename) + 1;
>  
> -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
>  	if (buflen)
>  		len += buflen + 1;
>  
> -- 
> 2.26.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:25     ` J. Bruce Fields
@ 2020-10-07 21:34       ` Trond Myklebust
  2020-10-07 21:45         ` bfields
  0 siblings, 1 reply; 10+ messages in thread
From: Trond Myklebust @ 2020-10-07 21:34 UTC (permalink / raw)
  To: bfields, trondmy; +Cc: linux-nfs, Anna.Schumaker

On Wed, 2020-10-07 at 17:25 -0400, J. Bruce Fields wrote:
> On Wed, Oct 07, 2020 at 05:07:20PM -0400, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > If a container sets a net namespace specific uniquifier,
> 
> What you're actually checking is if nn->nfs_client != NULL, and
> that's
> pretty much always true.  (The only time it's NULL is an allocation
> failure in some initialization code, I think.)
> 
> > +	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
> > +	struct nfs_netns_client *nn_clp = nn->nfs_client;
> > +	const char *id;
> > +	size_t len;
> > +
> >  	buf[0] = '\0';
> > +
> > +	if (nn_clp) {
> 
> Are you sure you don't mean
> 
> 	if (nn_clp->identifier)
> 
> ?
> 
> I think that's how you tell if someone's set it.

We're not holding the rcu_read_lock() here, so there is no point in
dereferencing the identifier pointer. That would cause a toctou race...

> 
> --b.
> 
> > +		rcu_read_lock();
> > +		id = rcu_dereference(nn_clp->identifier);
> > +		if (id && *id != '\0')
> > +			len = strlcpy(buf, id, buflen);
> > +		rcu_read_unlock();
> > +		if (len)
> > +			return len;

Oops. However I do need to ensure that 'len' is always initialised
here.

> > +	}
> > +
> >  	if (nfs4_client_id_uniquifier[0] != '\0')
> >  		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
> >  	return 0;
> > @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct
> > nfs_client *clp)
> >  		1;
> >  	rcu_read_unlock();
> >  
> > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> >  	if (buflen)
> >  		len += buflen + 1;
> >  
> > @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct
> > nfs_client *clp)
> >  	len = 10 + 10 + 1 + 10 + 1 +
> >  		strlen(clp->cl_rpcclient->cl_nodename) + 1;
> >  
> > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> >  	if (buflen)
> >  		len += buflen + 1;
> >  
> > -- 
> > 2.26.2
-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:34       ` Trond Myklebust
@ 2020-10-07 21:45         ` bfields
  0 siblings, 0 replies; 10+ messages in thread
From: bfields @ 2020-10-07 21:45 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: trondmy, linux-nfs, Anna.Schumaker

On Wed, Oct 07, 2020 at 09:34:17PM +0000, Trond Myklebust wrote:
> On Wed, 2020-10-07 at 17:25 -0400, J. Bruce Fields wrote:
> > On Wed, Oct 07, 2020 at 05:07:20PM -0400, trondmy@kernel.org wrote:
> > > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > > 
> > > If a container sets a net namespace specific uniquifier,
> > 
> > What you're actually checking is if nn->nfs_client != NULL, and
> > that's
> > pretty much always true.  (The only time it's NULL is an allocation
> > failure in some initialization code, I think.)
> > 
> > > +	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
> > > +	struct nfs_netns_client *nn_clp = nn->nfs_client;
> > > +	const char *id;
> > > +	size_t len;
> > > +
> > >  	buf[0] = '\0';
> > > +
> > > +	if (nn_clp) {
> > 
> > Are you sure you don't mean
> > 
> > 	if (nn_clp->identifier)
> > 
> > ?
> > 
> > I think that's how you tell if someone's set it.
> 
> We're not holding the rcu_read_lock() here, so there is no point in
> dereferencing the identifier pointer. That would cause a toctou race...

Oh, right:

> > > +		rcu_read_lock();
> > > +		id = rcu_dereference(nn_clp->identifier);
> > > +		if (id && *id != '\0')

My bad, I saw the first check and missed that one somehow.

> > > +			len = strlcpy(buf, id, buflen);
> > > +		rcu_read_unlock();
> > > +		if (len)
> > > +			return len;
> 
> Oops. However I do need to ensure that 'len' is always initialised
> here.

OK.--b.

> 
> > > +	}
> > > +
> > >  	if (nfs4_client_id_uniquifier[0] != '\0')
> > >  		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
> > >  	return 0;
> > > @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct
> > > nfs_client *clp)
> > >  		1;
> > >  	rcu_read_unlock();
> > >  
> > > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> > >  	if (buflen)
> > >  		len += buflen + 1;
> > >  
> > > @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct
> > > nfs_client *clp)
> > >  	len = 10 + 10 + 1 + 10 + 1 +
> > >  		strlen(clp->cl_rpcclient->cl_nodename) + 1;
> > >  
> > > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> > >  	if (buflen)
> > >  		len += buflen + 1;
> > >  
> > > -- 
> > > 2.26.2
> -- 
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:07   ` [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set trondmy
  2020-10-07 21:25     ` J. Bruce Fields
@ 2020-10-07 22:02     ` Dai Ngo
  2020-10-07 22:28       ` Trond Myklebust
  2020-10-07 22:40       ` kernel test robot
  2 siblings, 1 reply; 10+ messages in thread
From: Dai Ngo @ 2020-10-07 22:02 UTC (permalink / raw)
  To: trondmy, Anna Schumaker; +Cc: linux-nfs


On 10/7/20 2:07 PM, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> If a container sets a net namespace specific uniquifier, then use that
> in the setclientid/exchangeid process.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>   fs/nfs/nfs4proc.c | 23 ++++++++++++++++++++---
>   1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 3a39887e0e6e..a1dd46e7440b 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -63,6 +63,7 @@
>   #include "callback.h"
>   #include "pnfs.h"
>   #include "netns.h"
> +#include "sysfs.h"
>   #include "nfs4idmap.h"
>   #include "nfs4session.h"
>   #include "fscache.h"
> @@ -6007,9 +6008,25 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
>   }
>   
>   static size_t
> -nfs4_get_uniquifier(char *buf, size_t buflen)
> +nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
>   {
> +	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
> +	struct nfs_netns_client *nn_clp = nn->nfs_client;
> +	const char *id;
> +	size_t len;
> +
>   	buf[0] = '\0';
> +
> +	if (nn_clp) {
> +		rcu_read_lock();
> +		id = rcu_dereference(nn_clp->identifier);
> +		if (id && *id != '\0')
> +			len = strlcpy(buf, id, buflen);
> +		rcu_read_unlock();
> +		if (len)

I think 'len' can be uninitialized here.

-Dai

> +			return len;
> +	}
> +
>   	if (nfs4_client_id_uniquifier[0] != '\0')
>   		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
>   	return 0;
> @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
>   		1;
>   	rcu_read_unlock();
>   
> -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
>   	if (buflen)
>   		len += buflen + 1;
>   
> @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
>   	len = 10 + 10 + 1 + 10 + 1 +
>   		strlen(clp->cl_rpcclient->cl_nodename) + 1;
>   
> -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
>   	if (buflen)
>   		len += buflen + 1;
>   

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 22:02     ` Dai Ngo
@ 2020-10-07 22:28       ` Trond Myklebust
  0 siblings, 0 replies; 10+ messages in thread
From: Trond Myklebust @ 2020-10-07 22:28 UTC (permalink / raw)
  To: dai.ngo, Anna.Schumaker, trondmy; +Cc: linux-nfs

On Wed, 2020-10-07 at 15:02 -0700, Dai Ngo wrote:
> On 10/7/20 2:07 PM, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > If a container sets a net namespace specific uniquifier, then use
> > that
> > in the setclientid/exchangeid process.
> > 
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> >   fs/nfs/nfs4proc.c | 23 ++++++++++++++++++++---
> >   1 file changed, 20 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > index 3a39887e0e6e..a1dd46e7440b 100644
> > --- a/fs/nfs/nfs4proc.c
> > +++ b/fs/nfs/nfs4proc.c
> > @@ -63,6 +63,7 @@
> >   #include "callback.h"
> >   #include "pnfs.h"
> >   #include "netns.h"
> > +#include "sysfs.h"
> >   #include "nfs4idmap.h"
> >   #include "nfs4session.h"
> >   #include "fscache.h"
> > @@ -6007,9 +6008,25 @@ static void nfs4_init_boot_verifier(const
> > struct nfs_client *clp,
> >   }
> >   
> >   static size_t
> > -nfs4_get_uniquifier(char *buf, size_t buflen)
> > +nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t
> > buflen)
> >   {
> > +	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
> > +	struct nfs_netns_client *nn_clp = nn->nfs_client;
> > +	const char *id;
> > +	size_t len;
> > +
> >   	buf[0] = '\0';
> > +
> > +	if (nn_clp) {
> > +		rcu_read_lock();
> > +		id = rcu_dereference(nn_clp->identifier);
> > +		if (id && *id != '\0')
> > +			len = strlcpy(buf, id, buflen);
> > +		rcu_read_unlock();
> > +		if (len)
> 
> I think 'len' can be uninitialized here.

Thanks. Yes, already noted and fixed in v2.

> 
> -Dai
> 
> > +			return len;
> > +	}
> > +
> >   	if (nfs4_client_id_uniquifier[0] != '\0')
> >   		return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
> >   	return 0;
> > @@ -6034,7 +6051,7 @@ nfs4_init_nonuniform_client_string(struct
> > nfs_client *clp)
> >   		1;
> >   	rcu_read_unlock();
> >   
> > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> >   	if (buflen)
> >   		len += buflen + 1;
> >   
> > @@ -6081,7 +6098,7 @@ nfs4_init_uniform_client_string(struct
> > nfs_client *clp)
> >   	len = 10 + 10 + 1 + 10 + 1 +
> >   		strlen(clp->cl_rpcclient->cl_nodename) + 1;
> >   
> > -	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
> > +	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
> >   	if (buflen)
> >   		len += buflen + 1;
> >   
-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
  2020-10-07 21:07   ` [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set trondmy
@ 2020-10-07 22:40       ` kernel test robot
  2020-10-07 22:02     ` Dai Ngo
  2020-10-07 22:40       ` kernel test robot
  2 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-10-07 22:40 UTC (permalink / raw)
  To: trondmy, Anna Schumaker; +Cc: kbuild-all, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on nfs/linux-next]
[also build test WARNING on v5.9-rc8 next-20201007]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/trondmy-kernel-org/Give-containers-a-unique-client-id/20201008-050958
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: s390-randconfig-s032-20201008 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.2-218-gc0e96d6d-dirty
        # https://github.com/0day-ci/linux/commit/440cb74f8b835271bd5e1f6574dc9cb002cec5be
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review trondmy-kernel-org/Give-containers-a-unique-client-id/20201008-050958
        git checkout 440cb74f8b835271bd5e1f6574dc9cb002cec5be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=s390 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

echo
echo "sparse warnings: (new ones prefixed by >>)"
echo
>> fs/nfs/nfs4proc.c:6022:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> fs/nfs/nfs4proc.c:6022:22: sparse:    char const [noderef] __rcu *
>> fs/nfs/nfs4proc.c:6022:22: sparse:    char const *

vim +6022 fs/nfs/nfs4proc.c

  6009	
  6010	static size_t
  6011	nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
  6012	{
  6013		struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
  6014		struct nfs_netns_client *nn_clp = nn->nfs_client;
  6015		const char *id;
  6016		size_t len;
  6017	
  6018		buf[0] = '\0';
  6019	
  6020		if (nn_clp) {
  6021			rcu_read_lock();
> 6022			id = rcu_dereference(nn_clp->identifier);
  6023			if (id && *id != '\0')
  6024				len = strlcpy(buf, id, buflen);
  6025			rcu_read_unlock();
  6026			if (len)
  6027				return len;
  6028		}
  6029	
  6030		if (nfs4_client_id_uniquifier[0] != '\0')
  6031			return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
  6032		return 0;
  6033	}
  6034	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 20942 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set
@ 2020-10-07 22:40       ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2020-10-07 22:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2743 bytes --]

Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on nfs/linux-next]
[also build test WARNING on v5.9-rc8 next-20201007]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/trondmy-kernel-org/Give-containers-a-unique-client-id/20201008-050958
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: s390-randconfig-s032-20201008 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.2-218-gc0e96d6d-dirty
        # https://github.com/0day-ci/linux/commit/440cb74f8b835271bd5e1f6574dc9cb002cec5be
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review trondmy-kernel-org/Give-containers-a-unique-client-id/20201008-050958
        git checkout 440cb74f8b835271bd5e1f6574dc9cb002cec5be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=s390 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

echo
echo "sparse warnings: (new ones prefixed by >>)"
echo
>> fs/nfs/nfs4proc.c:6022:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> fs/nfs/nfs4proc.c:6022:22: sparse:    char const [noderef] __rcu *
>> fs/nfs/nfs4proc.c:6022:22: sparse:    char const *

vim +6022 fs/nfs/nfs4proc.c

  6009	
  6010	static size_t
  6011	nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
  6012	{
  6013		struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
  6014		struct nfs_netns_client *nn_clp = nn->nfs_client;
  6015		const char *id;
  6016		size_t len;
  6017	
  6018		buf[0] = '\0';
  6019	
  6020		if (nn_clp) {
  6021			rcu_read_lock();
> 6022			id = rcu_dereference(nn_clp->identifier);
  6023			if (id && *id != '\0')
  6024				len = strlcpy(buf, id, buflen);
  6025			rcu_read_unlock();
  6026			if (len)
  6027				return len;
  6028		}
  6029	
  6030		if (nfs4_client_id_uniquifier[0] != '\0')
  6031			return strlcpy(buf, nfs4_client_id_uniquifier, buflen);
  6032		return 0;
  6033	}
  6034	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 20942 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-07 22:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 21:07 [PATCH 0/2] Give containers a unique client id trondmy
2020-10-07 21:07 ` [PATCH 1/2] NFSv4: Clean up initialisation of uniquified client id strings trondmy
2020-10-07 21:07   ` [PATCH 2/2] NFSv4: Use the net namespace uniquifier if it is set trondmy
2020-10-07 21:25     ` J. Bruce Fields
2020-10-07 21:34       ` Trond Myklebust
2020-10-07 21:45         ` bfields
2020-10-07 22:02     ` Dai Ngo
2020-10-07 22:28       ` Trond Myklebust
2020-10-07 22:40     ` kernel test robot
2020-10-07 22:40       ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.