Skip to content

Commit 0a183f2

Browse files
neilbrownAnna Schumaker
authored andcommitted
NFSD: Handle @rqstp == NULL in check_nfsd_access()
LOCALIO-initiated open operations are not running in an nfsd thread and thus do not have an associated svc_rqst context. Signed-off-by: NeilBrown <[email protected]> Co-developed-by: Mike Snitzer <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 1545e48 commit 0a183f2

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

fs/nfsd/export.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,30 @@ static struct svc_export *exp_find(struct cache_detail *cd,
10741074
return exp;
10751075
}
10761076

1077+
/**
1078+
* check_nfsd_access - check if access to export is allowed.
1079+
* @exp: svc_export that is being accessed.
1080+
* @rqstp: svc_rqst attempting to access @exp (will be NULL for LOCALIO).
1081+
*
1082+
* Return values:
1083+
* %nfs_ok if access is granted, or
1084+
* %nfserr_wrongsec if access is denied
1085+
*/
10771086
__be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp)
10781087
{
10791088
struct exp_flavor_info *f, *end = exp->ex_flavors + exp->ex_nflavors;
1080-
struct svc_xprt *xprt = rqstp->rq_xprt;
1089+
struct svc_xprt *xprt;
1090+
1091+
/*
1092+
* If rqstp is NULL, this is a LOCALIO request which will only
1093+
* ever use a filehandle/credential pair for which access has
1094+
* been affirmed (by ACCESS or OPEN NFS requests) over the
1095+
* wire. So there is no need for further checks here.
1096+
*/
1097+
if (!rqstp)
1098+
return nfs_ok;
1099+
1100+
xprt = rqstp->rq_xprt;
10811101

10821102
if (exp->ex_xprtsec_modes & NFSEXP_XPRTSEC_NONE) {
10831103
if (!test_bit(XPT_TLS_SESSION, &xprt->xpt_flags))
@@ -1098,17 +1118,17 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp)
10981118
ok:
10991119
/* legacy gss-only clients are always OK: */
11001120
if (exp->ex_client == rqstp->rq_gssclient)
1101-
return 0;
1121+
return nfs_ok;
11021122
/* ip-address based client; check sec= export option: */
11031123
for (f = exp->ex_flavors; f < end; f++) {
11041124
if (f->pseudoflavor == rqstp->rq_cred.cr_flavor)
1105-
return 0;
1125+
return nfs_ok;
11061126
}
11071127
/* defaults in absence of sec= options: */
11081128
if (exp->ex_nflavors == 0) {
11091129
if (rqstp->rq_cred.cr_flavor == RPC_AUTH_NULL ||
11101130
rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
1111-
return 0;
1131+
return nfs_ok;
11121132
}
11131133

11141134
/* If the compound op contains a spo_must_allowed op,
@@ -1118,7 +1138,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp)
11181138
*/
11191139

11201140
if (nfsd4_spo_must_allow(rqstp))
1121-
return 0;
1141+
return nfs_ok;
11221142

11231143
denied:
11241144
return nfserr_wrongsec;

0 commit comments

Comments
 (0)