* [PATCH] nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen()
@ 2026-11-19 19:23 Dominik Maier
2026-11-19 21:45 ` Jeff Layton
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Maier @ 2026-11-19 19:23 UTC (permalink / raw)
To: Chuck Lever, Jeff Layton
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
dmnk+artist, Dominik Maier
As documented in nlm_fopen(), NFSD_MAY_BYPASS_GSS is intended to let NLM
clients using AUTH_SYS (RPC_AUTH_UNIX) lock files on Kerberos NFS
exports, whereas NLM clients using AUTH_NULL (RPC_AUTH_NULL) are only
meant to bypass authentication when NFSEXP_NOAUTHNLM (no_auth_nlm) is
enabled via NFSD_MAY_NLM.
However, nlm_fopen() has historically passed NFSD_MAY_BYPASS_GSS
unconditionally, and check_security_flavor() accepts both RPC_AUTH_UNIX
and RPC_AUTH_NULL whenever may_bypass_gss is true on an export with a
pseudoflavor >= RPC_AUTH_DES. Since commit bb4f07f2409c ("nfsd: Fix
NFSD_MAY_BYPASS_GSS and NFSD_MAY_BYPASS_GSS_ON_ROOT") restricted
may_bypass_gss to exports with pseudoflavor >= RPC_AUTH_DES, default
auth_nlm rejects RPC_AUTH_NULL NLM requests on sec=sys exports with
nfserr_wrongsec while still accepting RPC_AUTH_NULL NLM requests on
sec=krb5* exports even when no_auth_nlm is not set.
Only set NFSD_MAY_BYPASS_GSS in nlm_fopen() when rq_cred.cr_flavor is
RPC_AUTH_UNIX so auth_nlm and no_auth_nlm behave consistently across
sec=sys and GSS exports, requiring no_auth_nlm or an explicit sec=none
export flavor for RPC_AUTH_NULL NLM requests.
This issue was discovered by an AI-assisted code review tool (ARTIST),
validated in QEMU against an unmodified v7.4-rc3 kernel without kernel
modifications or error injection, build-tested with KCFLAGS=-Werror, and
checked with checkpatch.pl --strict.
Signed-off-by: Dominik Maier <dmnk@google.com>
---
fs/nfsd/lockd.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index f24e45d..2683939 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -41,8 +41,8 @@ static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f,
fh.fh_export = NULL;
/*
- * Allow BYPASS_GSS as some client implementations use AUTH_SYS
- * for NLM even when GSS is used for NFS.
+ * Allow BYPASS_GSS for AUTH_SYS as some client implementations use
+ * AUTH_SYS for NLM even when GSS is used for NFS.
* Allow OWNER_OVERRIDE as permission might have been changed
* after the file was opened.
* Pass MAY_NLM so that authentication can be completely bypassed
@@ -50,7 +50,9 @@ static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f,
* for NLM requests.
*/
access = (flags == O_WRONLY) ? NFSD_MAY_WRITE : NFSD_MAY_READ;
- access |= NFSD_MAY_NLM | NFSD_MAY_OWNER_OVERRIDE | NFSD_MAY_BYPASS_GSS;
+ access |= NFSD_MAY_NLM | NFSD_MAY_OWNER_OVERRIDE;
+ if (rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
+ access |= NFSD_MAY_BYPASS_GSS;
nfserr = nfsd_open(rqstp, &fh, S_IFREG, access, filp);
fh_put(&fh);
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen()
2026-11-19 19:23 [PATCH] nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen() Dominik Maier
@ 2026-11-19 21:45 ` Jeff Layton
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2026-11-19 21:45 UTC (permalink / raw)
To: Dominik Maier, Chuck Lever
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
dmnk+artist
On Thu, 2026-11-19 at 20:23 +0100, Dominik Maier wrote:
> As documented in nlm_fopen(), NFSD_MAY_BYPASS_GSS is intended to let NLM
> clients using AUTH_SYS (RPC_AUTH_UNIX) lock files on Kerberos NFS
> exports, whereas NLM clients using AUTH_NULL (RPC_AUTH_NULL) are only
> meant to bypass authentication when NFSEXP_NOAUTHNLM (no_auth_nlm) is
> enabled via NFSD_MAY_NLM.
>
> However, nlm_fopen() has historically passed NFSD_MAY_BYPASS_GSS
> unconditionally, and check_security_flavor() accepts both RPC_AUTH_UNIX
> and RPC_AUTH_NULL whenever may_bypass_gss is true on an export with a
> pseudoflavor >= RPC_AUTH_DES. Since commit bb4f07f2409c ("nfsd: Fix
> NFSD_MAY_BYPASS_GSS and NFSD_MAY_BYPASS_GSS_ON_ROOT") restricted
> may_bypass_gss to exports with pseudoflavor >= RPC_AUTH_DES, default
> auth_nlm rejects RPC_AUTH_NULL NLM requests on sec=sys exports with
> nfserr_wrongsec while still accepting RPC_AUTH_NULL NLM requests on
> sec=krb5* exports even when no_auth_nlm is not set.
>
> Only set NFSD_MAY_BYPASS_GSS in nlm_fopen() when rq_cred.cr_flavor is
> RPC_AUTH_UNIX so auth_nlm and no_auth_nlm behave consistently across
> sec=sys and GSS exports, requiring no_auth_nlm or an explicit sec=none
> export flavor for RPC_AUTH_NULL NLM requests.
>
> This issue was discovered by an AI-assisted code review tool (ARTIST),
> validated in QEMU against an unmodified v7.4-rc3 kernel without kernel
> modifications or error injection, build-tested with KCFLAGS=-Werror, and
> checked with checkpatch.pl --strict.
>
Sashiko suggests:
Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK")
> Signed-off-by: Dominik Maier <dmnk@google.com>
> ---
> fs/nfsd/lockd.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
> index f24e45d..2683939 100644
> --- a/fs/nfsd/lockd.c
> +++ b/fs/nfsd/lockd.c
> @@ -41,8 +41,8 @@ static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f,
> fh.fh_export = NULL;
>
> /*
> - * Allow BYPASS_GSS as some client implementations use AUTH_SYS
> - * for NLM even when GSS is used for NFS.
> + * Allow BYPASS_GSS for AUTH_SYS as some client implementations use
> + * AUTH_SYS for NLM even when GSS is used for NFS.
> * Allow OWNER_OVERRIDE as permission might have been changed
> * after the file was opened.
> * Pass MAY_NLM so that authentication can be completely bypassed
> @@ -50,7 +50,9 @@ static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f,
> * for NLM requests.
> */
> access = (flags == O_WRONLY) ? NFSD_MAY_WRITE : NFSD_MAY_READ;
> - access |= NFSD_MAY_NLM | NFSD_MAY_OWNER_OVERRIDE | NFSD_MAY_BYPASS_GSS;
> + access |= NFSD_MAY_NLM | NFSD_MAY_OWNER_OVERRIDE;
> + if (rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
> + access |= NFSD_MAY_BYPASS_GSS;
> nfserr = nfsd_open(rqstp, &fh, S_IFREG, access, filp);
> fh_put(&fh);
>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 21:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:23 [PATCH] nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen() Dominik Maier
2026-11-19 21:45 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox