Skip to content

Commit f1442d6

Browse files
dkobraschucklever
authored andcommitted
sunrpc: fix refcount leak for rpc auth modules
If an auth module's accept op returns SVC_CLOSE, svc_process_common() enters a call path that does not call svc_authorise() before leaving the function, and thus leaks a reference on the auth module's refcount. Hence, make sure calls to svc_authenticate() and svc_authorise() are paired for all call paths, to make sure rpc auth modules can be unloaded. Signed-off-by: Daniel Kobras <kobras@puzzle-itc.de> Fixes: 4d712ef ("svcauth_gss: Close connection when dropping an incoming message") Link: https://lore.kernel.org/linux-nfs/3F1B347F-B809-478F-A1E9-0BE98E22B0F0@oracle.com/T/#t Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent c7de87f commit f1442d6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/sunrpc/svc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
14131413

14141414
sendit:
14151415
if (svc_authorise(rqstp))
1416-
goto close;
1416+
goto close_xprt;
14171417
return 1; /* Caller can now send it */
14181418

14191419
release_dropit:
@@ -1425,6 +1425,8 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
14251425
return 0;
14261426

14271427
close:
1428+
svc_authorise(rqstp);
1429+
close_xprt:
14281430
if (rqstp->rq_xprt && test_bit(XPT_TEMP, &rqstp->rq_xprt->xpt_flags))
14291431
svc_close_xprt(rqstp->rq_xprt);
14301432
dprintk("svc: svc_process close\n");
@@ -1433,7 +1435,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
14331435
err_short_len:
14341436
svc_printk(rqstp, "short len %zd, dropping request\n",
14351437
argv->iov_len);
1436-
goto close;
1438+
goto close_xprt;
14371439

14381440
err_bad_rpc:
14391441
serv->sv_stats->rpcbadfmt++;

0 commit comments

Comments
 (0)