All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfsd: Fix nfs4_disable_idmapping option
@ 2024-09-12 22:06 Pali Rohár
  2024-09-12 22:26 ` NeilBrown
  0 siblings, 1 reply; 5+ messages in thread
From: Pali Rohár @ 2024-09-12 22:06 UTC (permalink / raw)
  To: Chuck Lever, Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo,
	Tom Talpey
  Cc: linux-nfs, linux-kernel

NFSv4 server option nfs4_disable_idmapping says that it turn off server's
NFSv4 idmapping when using 'sec=sys'. But it also turns idmapping off also
for 'sec=none'.

NFSv4 client option nfs4_disable_idmapping says same thing and really it
turns the NFSv4 idmapping only for 'sec=sys'.

Fix the NFSv4 server option nfs4_disable_idmapping to turn off idmapping
only for 'sec=sys'. This aligns the server nfs4_disable_idmapping option
with its description and also aligns behavior with the client option.

Signed-off-by: Pali Rohár <pali@kernel.org>
Cc: stable@vger.kernel.org
---
 fs/nfsd/nfs4idmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 7a806ac13e31..641293711f53 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -620,7 +620,7 @@ numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namel
 static __be32
 do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
 {
-	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
+	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
 		if (numeric_name_to_id(rqstp, type, name, namelen, id))
 			return 0;
 		/*
@@ -633,7 +633,7 @@ do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u
 static __be32 encode_name_from_id(struct xdr_stream *xdr,
 				  struct svc_rqst *rqstp, int type, u32 id)
 {
-	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
+	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
 		return encode_ascii_id(xdr, id);
 	return idmap_id_to_name(xdr, rqstp, type, id);
 }
-- 
2.20.1


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

* Re: [PATCH] nfsd: Fix nfs4_disable_idmapping option
  2024-09-12 22:06 [PATCH] nfsd: Fix nfs4_disable_idmapping option Pali Rohár
@ 2024-09-12 22:26 ` NeilBrown
  2024-09-12 22:38   ` Pali Rohár
  0 siblings, 1 reply; 5+ messages in thread
From: NeilBrown @ 2024-09-12 22:26 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Chuck Lever, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	linux-nfs, linux-kernel

On Fri, 13 Sep 2024, Pali Rohár wrote:
> NFSv4 server option nfs4_disable_idmapping says that it turn off server's
> NFSv4 idmapping when using 'sec=sys'. But it also turns idmapping off also
> for 'sec=none'.
> 
> NFSv4 client option nfs4_disable_idmapping says same thing and really it
> turns the NFSv4 idmapping only for 'sec=sys'.
> 
> Fix the NFSv4 server option nfs4_disable_idmapping to turn off idmapping
> only for 'sec=sys'. This aligns the server nfs4_disable_idmapping option
> with its description and also aligns behavior with the client option.

Why do you think this is the right approach?
If the documentation says "turn off when sec=sys" and the implementation
does "turn off when sec=sys or sec=none" then I agree that something
needs to be fixed.  I would suggest that the documentation should be
fixed.

From the perspective of id mapping, sec=none is similar to sec=sys.

NeilBrown


> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Cc: stable@vger.kernel.org
> ---
>  fs/nfsd/nfs4idmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> index 7a806ac13e31..641293711f53 100644
> --- a/fs/nfsd/nfs4idmap.c
> +++ b/fs/nfsd/nfs4idmap.c
> @@ -620,7 +620,7 @@ numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namel
>  static __be32
>  do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
>  {
> -	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
> +	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
>  		if (numeric_name_to_id(rqstp, type, name, namelen, id))
>  			return 0;
>  		/*
> @@ -633,7 +633,7 @@ do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u
>  static __be32 encode_name_from_id(struct xdr_stream *xdr,
>  				  struct svc_rqst *rqstp, int type, u32 id)
>  {
> -	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
> +	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
>  		return encode_ascii_id(xdr, id);
>  	return idmap_id_to_name(xdr, rqstp, type, id);
>  }
> -- 
> 2.20.1
> 
> 


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

* Re: [PATCH] nfsd: Fix nfs4_disable_idmapping option
  2024-09-12 22:26 ` NeilBrown
@ 2024-09-12 22:38   ` Pali Rohár
  2024-09-12 23:03     ` NeilBrown
  0 siblings, 1 reply; 5+ messages in thread
From: Pali Rohár @ 2024-09-12 22:38 UTC (permalink / raw)
  To: NeilBrown
  Cc: Chuck Lever, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	linux-nfs, linux-kernel

On Friday 13 September 2024 08:26:02 NeilBrown wrote:
> On Fri, 13 Sep 2024, Pali Rohár wrote:
> > NFSv4 server option nfs4_disable_idmapping says that it turn off server's
> > NFSv4 idmapping when using 'sec=sys'. But it also turns idmapping off also
> > for 'sec=none'.
> > 
> > NFSv4 client option nfs4_disable_idmapping says same thing and really it
> > turns the NFSv4 idmapping only for 'sec=sys'.
> > 
> > Fix the NFSv4 server option nfs4_disable_idmapping to turn off idmapping
> > only for 'sec=sys'. This aligns the server nfs4_disable_idmapping option
> > with its description and also aligns behavior with the client option.
> 
> Why do you think this is the right approach?

I thought it because client has same configuration option, client is
already doing it, client documentation says it and also server
documentation says it. I just saw too many pieces which agreed on it and
just server implementation did not follow it.

And to make mapping usable, both sides (client and server) have to agree
on the configuration.

So instead of changing also client and client's documentation it is
easier to just fix the server.

> If the documentation says "turn off when sec=sys" and the implementation
> does "turn off when sec=sys or sec=none" then I agree that something
> needs to be fixed.  I would suggest that the documentation should be
> fixed.
> 
> From the perspective of id mapping, sec=none is similar to sec=sys.

It is similar, but quite different. With sec=sys client sends its uid
and list of gids in every (RPC) packet and server authenticate client
(and do mapping) based on it. With sec=none client does not send any uid
or gid. So mostly uid/gid form is tight to sec=sys.

> NeilBrown
> 
> 
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > Cc: stable@vger.kernel.org
> > ---
> >  fs/nfsd/nfs4idmap.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> > index 7a806ac13e31..641293711f53 100644
> > --- a/fs/nfsd/nfs4idmap.c
> > +++ b/fs/nfsd/nfs4idmap.c
> > @@ -620,7 +620,7 @@ numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namel
> >  static __be32
> >  do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u32 *id)
> >  {
> > -	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
> > +	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
> >  		if (numeric_name_to_id(rqstp, type, name, namelen, id))
> >  			return 0;
> >  		/*
> > @@ -633,7 +633,7 @@ do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u
> >  static __be32 encode_name_from_id(struct xdr_stream *xdr,
> >  				  struct svc_rqst *rqstp, int type, u32 id)
> >  {
> > -	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
> > +	if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
> >  		return encode_ascii_id(xdr, id);
> >  	return idmap_id_to_name(xdr, rqstp, type, id);
> >  }
> > -- 
> > 2.20.1
> > 
> > 
> 

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

* Re: [PATCH] nfsd: Fix nfs4_disable_idmapping option
  2024-09-12 22:38   ` Pali Rohár
@ 2024-09-12 23:03     ` NeilBrown
  2024-09-13 15:25       ` Chuck Lever
  0 siblings, 1 reply; 5+ messages in thread
From: NeilBrown @ 2024-09-12 23:03 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Chuck Lever, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	linux-nfs, linux-kernel

On Fri, 13 Sep 2024, Pali Rohár wrote:
> On Friday 13 September 2024 08:26:02 NeilBrown wrote:
> > On Fri, 13 Sep 2024, Pali Rohár wrote:
> > > NFSv4 server option nfs4_disable_idmapping says that it turn off server's
> > > NFSv4 idmapping when using 'sec=sys'. But it also turns idmapping off also
> > > for 'sec=none'.
> > > 
> > > NFSv4 client option nfs4_disable_idmapping says same thing and really it
> > > turns the NFSv4 idmapping only for 'sec=sys'.
> > > 
> > > Fix the NFSv4 server option nfs4_disable_idmapping to turn off idmapping
> > > only for 'sec=sys'. This aligns the server nfs4_disable_idmapping option
> > > with its description and also aligns behavior with the client option.
> > 
> > Why do you think this is the right approach?
> 
> I thought it because client has same configuration option, client is
> already doing it, client documentation says it and also server
> documentation says it. I just saw too many pieces which agreed on it and
> just server implementation did not follow it.
> 
> And to make mapping usable, both sides (client and server) have to agree
> on the configuration.
> 
> So instead of changing also client and client's documentation it is
> easier to just fix the server.
> 
> > If the documentation says "turn off when sec=sys" and the implementation
> > does "turn off when sec=sys or sec=none" then I agree that something
> > needs to be fixed.  I would suggest that the documentation should be
> > fixed.
> > 
> > From the perspective of id mapping, sec=none is similar to sec=sys.
> 
> It is similar, but quite different. With sec=sys client sends its uid
> and list of gids in every (RPC) packet and server authenticate client
> (and do mapping) based on it. With sec=none client does not send any uid
> or gid. So mostly uid/gid form is tight to sec=sys.
> 

With sec=none I don't think that any mapping makes sense except to map
all uids and gids to "none" or similar.

The documented purpose of nfs4_disable_idmapping is to "ease migration
from NFSv2/v3".  That suggests that where relevant it should behave
mostly like v2/v3.

I don't feel strongly about this.  You appear to be actually using
AUTH_NONE authentication.  What behaviour would work best for your
use-case, and why?

NeilBrown

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

* Re: [PATCH] nfsd: Fix nfs4_disable_idmapping option
  2024-09-12 23:03     ` NeilBrown
@ 2024-09-13 15:25       ` Chuck Lever
  0 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2024-09-13 15:25 UTC (permalink / raw)
  To: NeilBrown
  Cc: Pali Rohár, Jeff Layton, Olga Kornievskaia, Dai Ngo,
	Tom Talpey, linux-nfs, linux-kernel

On Fri, Sep 13, 2024 at 09:03:00AM +1000, NeilBrown wrote:
> On Fri, 13 Sep 2024, Pali Rohár wrote:
> > On Friday 13 September 2024 08:26:02 NeilBrown wrote:
> > > On Fri, 13 Sep 2024, Pali Rohár wrote:
> > > > NFSv4 server option nfs4_disable_idmapping says that it turn off server's
> > > > NFSv4 idmapping when using 'sec=sys'. But it also turns idmapping off also
> > > > for 'sec=none'.
> > > > 
> > > > NFSv4 client option nfs4_disable_idmapping says same thing and really it
> > > > turns the NFSv4 idmapping only for 'sec=sys'.
> > > > 
> > > > Fix the NFSv4 server option nfs4_disable_idmapping to turn off idmapping
> > > > only for 'sec=sys'. This aligns the server nfs4_disable_idmapping option
> > > > with its description and also aligns behavior with the client option.
> > > 
> > > Why do you think this is the right approach?
> > 
> > I thought it because client has same configuration option, client is
> > already doing it, client documentation says it and also server
> > documentation says it. I just saw too many pieces which agreed on it and
> > just server implementation did not follow it.
> > 
> > And to make mapping usable, both sides (client and server) have to agree
> > on the configuration.
> > 
> > So instead of changing also client and client's documentation it is
> > easier to just fix the server.
> > 
> > > If the documentation says "turn off when sec=sys" and the implementation
> > > does "turn off when sec=sys or sec=none" then I agree that something
> > > needs to be fixed.  I would suggest that the documentation should be
> > > fixed.
> > > 
> > > From the perspective of id mapping, sec=none is similar to sec=sys.
> > 
> > It is similar, but quite different. With sec=sys client sends its uid
> > and list of gids in every (RPC) packet and server authenticate client
> > (and do mapping) based on it. With sec=none client does not send any uid
> > or gid. So mostly uid/gid form is tight to sec=sys.
> > 
> 
> With sec=none I don't think that any mapping makes sense except to map
> all uids and gids to "none" or similar.

I tend to agree that "sec=none" on the server should be akin to
squashing all RPC users to the local "nobody" identity. But I
haven't looked closely at NFSD's implementation of this security
flavor.


> The documented purpose of nfs4_disable_idmapping is to "ease migration
> from NFSv2/v3".  That suggests that where relevant it should behave
> mostly like v2/v3.
> 
> I don't feel strongly about this.  You appear to be actually using
> AUTH_NONE authentication.  What behaviour would work best for your
> use-case, and why?

Or to ask another way, what isn't working for you, exactly?

The problem statement above says "The server doesn't work like the
client" but does not explain why that's a problem.

-- 
Chuck Lever

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

end of thread, other threads:[~2024-09-13 15:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 22:06 [PATCH] nfsd: Fix nfs4_disable_idmapping option Pali Rohár
2024-09-12 22:26 ` NeilBrown
2024-09-12 22:38   ` Pali Rohár
2024-09-12 23:03     ` NeilBrown
2024-09-13 15:25       ` Chuck Lever

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.