Skip to contentSkip to conversation

nfsd: fix __fh_verify for localio

PATCH In review Olga Kornievskaia 3 participants 3 messages Jan 28, 2025

Subsystems (2)
lore
Share & tools
lore

Olga Kornievskaia

author reviewer
#0 lore raw

PATCH 1/1 nfsd: fix __fh_verify for localio

__fh_verify() added a call to svc_xprt_set_valid() to help do connection management but during LOCALIO path rqstp argument is NULL, leading to NULL pointer dereferencing and a crash.

Fixes eccbbc7c00a5 ("nfsd: don't use sv_nrthreads in connection limiting calculations.")
---
 fs/nfsd/nfsfh.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfsfh.c +3 -2
index bf59f83c6224..91bf0e6d5895 100644
@@ -381,8 +381,9 @@ __fh_verify(struct svc_rqst *rqstp,
 	error = check_nfsd_access(exp, rqstp, may_bypass_gss);
 	if (error)
 		goto out;
-
-	svc_xprt_set_valid(rqstp->rq_xprt);
+	/* During LOCALIO call to fh_verify will be called with a NULL rqstp */
+	if (rqstp)
+		svc_xprt_set_valid(rqstp->rq_xprt);
 
 	/* Finally, check access permissions. */
 	error = nfsd_permission(cred, exp, dentry, access);
Signature · 1 line
2.47.1
#1 lore raw

From: Chuck Lever <[email protected]>

Quoted 5 lines · Olga Kornievskaia

__fh_verify() added a call to svc_xprt_set_valid() to help do connection management but during LOCALIO path rqstp argument is NULL, leading to NULL pointer dereferencing and a crash.

Applied to nfsd-testing, thanks!

[1/1] nfsd: fix __fh_verify for localio

      commit: 3c6a376bcbc815e3bdae0816b32e600c4c63599e

--
Chuck Lever

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Olga Kornievskaia
Quoted 16 lines · Olga Kornievskaia

__fh_verify() added a call to svc_xprt_set_valid() to help do connection management but during LOCALIO path rqstp argument is NULL, leading to NULL pointer dereferencing and a crash.

Fixes eccbbc7c00a5 ("nfsd: don't use sv_nrthreads in connection limiting calculations.")
---
 fs/nfsd/nfsfh.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfsfh.c +0 -0
index bf59f83c6224..91bf0e6d5895 100644
@@ -381,8 +381,9 @@ __fh_verify(struct svc_rqst *rqstp,
 	error = check_nfsd_access(exp, rqstp, may_bypass_gss);

fs/nfsd/nfsfh.c __fh_verify(struct svc_rqst *rqstp, · line 389

Quoted 10 lines
fs/nfsd/nfsfh.c +3 -2
 	if (error)
 		goto out;
-
-	svc_xprt_set_valid(rqstp->rq_xprt);
+	/* During LOCALIO call to fh_verify will be called with a NULL rqstp */
+	if (rqstp)
+		svc_xprt_set_valid(rqstp->rq_xprt);
 
 	/* Finally, check access permissions. */
 	error = nfsd_permission(cred, exp, dentry, access);

Nice catch!