Skip to contentSkip to conversation

lockd: fix GRANTED_MSG handling

PATCH In review Olga Kornievskaia 3 participants 3 messages Jun 25 – Jun 26

Subsystems (2)
lore
Share & tools
lore

Olga Kornievskaia

author reviewer
#0 lore raw

PATCH 1/1 lockd: fix GRANTED_MSG handling

GRANTED_MSG is a server-to-client callback, so it runs on the client, where nfsd never registers nlmsvc_ops. The nlm4svc_lookup_host()/ nlm3svc_lookup_host() helpers are for the server-side request handlers (TEST/LOCK/CANCEL/UNLOCK), which reach nlmsvc_ops->fopen and must reject requests when nfsd isn't running. GRANTED_MSG only calls nlmclnt_grant(). Instead, of calling nlm4svc_lookup_host()/ nlm3svc_lookup_host() (which results in a client failing a GRANTED_MSG call) call nlmsvc_lookup_host.

Fixes 62721885e861 ("lockd: Use xdrgen XDR functions for the NLMv4 GRANTED_MSG procedure")
Fixes 6c534ad999b6 ("lockd: Use xdrgen XDR functions for the NLMv3 GRANTED_MSG procedure")
---
 fs/lockd/svc4proc.c | 3 ++-
 fs/lockd/svcproc.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
fs/lockd/svc4proc.c +2 -1
index 080dffce9d8e..b73004a7987e 100644
@@ -872,7 +872,8 @@ static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp)
 	struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
 	struct nlm_host *host;
 
-	host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
+	host = nlmsvc_lookup_host(rqstp, argp->xdrgen.alock.caller_name.data,
+				  argp->xdrgen.alock.caller_name.len);
 	if (!host)
 		return rpc_system_err;
 
fs/lockd/svcproc.c +2 -1
index dce6f6e3fd40..d410b8c69893 100644
@@ -901,7 +901,8 @@ static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp)
 	if (argp->xdrgen.cookie.len > NLM_MAXCOOKIELEN)
 		return rpc_garbage_args;
 
-	host = nlm3svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
+	host = nlmsvc_lookup_host(rqstp, argp->xdrgen.alock.caller_name.data,
+				  argp->xdrgen.alock.caller_name.len);
 	if (!host)
 		return rpc_system_err;
 
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Olga Kornievskaia

GRANTED_MSG is a server-to-client callback, so it runs on the client, where nfsd never registers nlmsvc_ops. The nlm4svc_lookup_host()/ nlm3svc_lookup_host() helpers are for the server-side request handlers (TEST/LOCK/CANCEL/UNLOCK), which reach nlmsvc_ops->fopen and must reject requests when nfsd isn't running. GRANTED_MSG only calls nlmclnt_grant(). Instead, of calling nlm4svc_lookup_host()/ nlm3svc_lookup_host() (which results in a client failing a GRANTED_MSG call) call nlmsvc_lookup_host.

Fixes 62721885e861 ("lockd: Use xdrgen XDR functions for the NLMv4 GRANTED_MSG procedure")
Fixes 6c534ad999b6 ("lockd: Use xdrgen XDR functions for the NLMv3 GRANTED_MSG procedure")
---
 fs/lockd/svc4proc.c | 3 ++-
 fs/lockd/svcproc.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
fs/lockd/svc4proc.c +2 -1
index 080dffce9d8e..b73004a7987e 100644
@@ -872,7 +872,8 @@ static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp)
 	struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
 	struct nlm_host *host;
 
-	host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
+	host = nlmsvc_lookup_host(rqstp, argp->xdrgen.alock.caller_name.data,
+				  argp->xdrgen.alock.caller_name.len);
 	if (!host)
 		return rpc_system_err;
 
fs/lockd/svcproc.c +0 -0
index dce6f6e3fd40..d410b8c69893 100644

fs/lockd/svcproc.c static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp) · line 908

Quoted 9 lines
fs/lockd/svcproc.c +2 -1
@@ -901,7 +901,8 @@ static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp)
 	if (argp->xdrgen.cookie.len > NLM_MAXCOOKIELEN)
 		return rpc_garbage_args;
 
-	host = nlm3svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
+	host = nlmsvc_lookup_host(rqstp, argp->xdrgen.alock.caller_name.data,
+				  argp->xdrgen.alock.caller_name.len);
 	if (!host)
 		return rpc_system_err;
 

That is a subtle difference between nlm4svc_lookup_host() and nlmsvc_lookup_host(). I wonder if making the names more distinct would help...

Thanks,
NeilBrown

maintainer
#2 lore raw
In reply to Olga Kornievskaia
Quoted 9 lines · Olga Kornievskaia

GRANTED_MSG is a server-to-client callback, so it runs on the client, where nfsd never registers nlmsvc_ops. The nlm4svc_lookup_host()/ nlm3svc_lookup_host() helpers are for the server-side request handlers (TEST/LOCK/CANCEL/UNLOCK), which reach nlmsvc_ops->fopen and must reject requests when nfsd isn't running. GRANTED_MSG only calls nlmclnt_grant(). Instead, of calling nlm4svc_lookup_host()/ nlm3svc_lookup_host() (which results in a client failing a GRANTED_MSG call) call nlmsvc_lookup_host.

Quoted 5 lines
Fixes 62721885e861 ("lockd: Use xdrgen XDR functions for the NLMv4

GRANTED_MSG procedure")

Fixes 6c534ad999b6 ("lockd: Use xdrgen XDR functions for the NLMv3

GRANTED_MSG procedure")

The fix LGTM.

Looking at this now, I see the patch targets two distinct stable kernels. Therefore IMO this does actually need to be two separate patches. I will split the patch when I apply it to nfsd-testing.

Signature · 1 line
Chuck Lever