@@ -1074,10 +1074,30 @@ static struct svc_export *exp_find(struct cache_detail *cd,
1074
1074
return exp ;
1075
1075
}
1076
1076
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
+ */
1077
1086
__be32 check_nfsd_access (struct svc_export * exp , struct svc_rqst * rqstp )
1078
1087
{
1079
1088
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 ;
1081
1101
1082
1102
if (exp -> ex_xprtsec_modes & NFSEXP_XPRTSEC_NONE ) {
1083
1103
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)
1098
1118
ok :
1099
1119
/* legacy gss-only clients are always OK: */
1100
1120
if (exp -> ex_client == rqstp -> rq_gssclient )
1101
- return 0 ;
1121
+ return nfs_ok ;
1102
1122
/* ip-address based client; check sec= export option: */
1103
1123
for (f = exp -> ex_flavors ; f < end ; f ++ ) {
1104
1124
if (f -> pseudoflavor == rqstp -> rq_cred .cr_flavor )
1105
- return 0 ;
1125
+ return nfs_ok ;
1106
1126
}
1107
1127
/* defaults in absence of sec= options: */
1108
1128
if (exp -> ex_nflavors == 0 ) {
1109
1129
if (rqstp -> rq_cred .cr_flavor == RPC_AUTH_NULL ||
1110
1130
rqstp -> rq_cred .cr_flavor == RPC_AUTH_UNIX )
1111
- return 0 ;
1131
+ return nfs_ok ;
1112
1132
}
1113
1133
1114
1134
/* 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)
1118
1138
*/
1119
1139
1120
1140
if (nfsd4_spo_must_allow (rqstp ))
1121
- return 0 ;
1141
+ return nfs_ok ;
1122
1142
1123
1143
denied :
1124
1144
return nfserr_wrongsec ;
0 commit comments