nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen()
Subsystems (2)
PATCH 1/1 nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen()
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.
--- fs/nfsd/lockd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/nfsd/lockd.c +5 -3
@@ -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);
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
Quoted 21 lines · Dominik Maier
As documented in
nlm_fopen(),NFSD_MAY_BYPASS_GSSis intended to let NLM clients usingAUTH_SYS(RPC_AUTH_UNIX) lock files on Kerberos NFS exports, whereas NLM clients usingAUTH_NULL(RPC_AUTH_NULL) are only meant to bypass authentication whenNFSEXP_NOAUTHNLM(no_auth_nlm) is enabled viaNFSD_MAY_NLM.However,
nlm_fopen()has historically passedNFSD_MAY_BYPASS_GSSunconditionally, andcheck_security_flavor()accepts bothRPC_AUTH_UNIXandRPC_AUTH_NULLwhenevermay_bypass_gssis true on an export with a pseudoflavor >=RPC_AUTH_DES. Since commitbb4f07f2409c("nfsd: FixNFSD_MAY_BYPASS_GSSandNFSD_MAY_BYPASS_GSS_ON_ROOT") restrictedmay_bypass_gssto exports with pseudoflavor >=RPC_AUTH_DES, defaultauth_nlmrejectsRPC_AUTH_NULLNLM requests on sec=sys exports withnfserr_wrongsecwhile still acceptingRPC_AUTH_NULLNLM requests on sec=krb5* exports even whenno_auth_nlmis not set.Only set
NFSD_MAY_BYPASS_GSSinnlm_fopen()when rq_cred.cr_flavor isRPC_AUTH_UNIXsoauth_nlmandno_auth_nlmbehave consistently across sec=sys and GSS exports, requiringno_auth_nlmor an explicit sec=none export flavor forRPC_AUTH_NULLNLM requests.
Quoted 5 lines
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:
Quoted 21 lines
Signed-off-by Dominik Maier <[email protected]>--- fs/nfsd/lockd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)fs/nfsd/lockd.c +2
-2@@ -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
fs/nfsd/lockd.c static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, · line 58
Quoted 10 lines
fs/nfsd/lockd.c +3
-1@@ -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);
Chuck Lever
maintainerQuoted 16 lines · Dominik Maier
As documented in
nlm_fopen(),NFSD_MAY_BYPASS_GSSis intended to let NLM clients usingAUTH_SYS(RPC_AUTH_UNIX) lock files on Kerberos NFS exports, whereas NLM clients usingAUTH_NULL(RPC_AUTH_NULL) are only meant to bypass authentication whenNFSEXP_NOAUTHNLM(no_auth_nlm) is enabled viaNFSD_MAY_NLM.However,
nlm_fopen()has historically passedNFSD_MAY_BYPASS_GSSunconditionally, andcheck_security_flavor()accepts bothRPC_AUTH_UNIXandRPC_AUTH_NULLwhenevermay_bypass_gssis true on an export with a pseudoflavor >=RPC_AUTH_DES. Since commitbb4f07f2409c("nfsd: FixNFSD_MAY_BYPASS_GSSandNFSD_MAY_BYPASS_GSS_ON_ROOT") restrictedmay_bypass_gssto exports with pseudoflavor >=RPC_AUTH_DES, defaultauth_nlmrejectsRPC_AUTH_NULLNLM requests on sec=sys exports withnfserr_wrongsecwhile still acceptingRPC_AUTH_NULLNLM requests on sec=krb5* exports even whenno_auth_nlmis not set.
Quoted 1 line
[...]
Applied to nfsd-testing, thanks!
[1/1] nfsd: only set NFSD_MAY_BYPASS_GSS for RPC_AUTH_UNIX in nlm_fopen()
commit: 824294e1f20b5dbd8420e77ddb3da230150f96c1
--
Chuck Lever <[email protected]>