diff mbox

SUNRPC: Make sure authorize svc when meeting SVC_CLOSE

Message ID 090f6673-1bb3-d626-e27e-6be5afcda782@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee Jan. 16, 2017, 12:23 a.m. UTC
Commit 4d712ef1db05 "svcauth_gss: Close connection when
 dropping an incoming message" will close connection,
but forget authorizing the svc when meeting SVC_CLOSE.

That, there will be an module reference to sunrpc,
and some memory leak.

When mounting an nfs filesystem, the reference leak increase one.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 net/sunrpc/svc.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

J. Bruce Fields Jan. 18, 2017, 10:20 p.m. UTC | #1
On Mon, Jan 16, 2017 at 08:23:37AM +0800, Kinglong Mee wrote:
> Commit 4d712ef1db05 "svcauth_gss: Close connection when
>  dropping an incoming message" will close connection,
> but forget authorizing the svc when meeting SVC_CLOSE.
> 
> That, there will be an module reference to sunrpc,
> and some memory leak.
> 
> When mounting an nfs filesystem, the reference leak increase one.

Thanks, applying for 4.10.

(I'm not too happy with this function--e.g. it'd be easier to avoid this
sort of bug if we had a single unavoidable common exit that always
called svc_authenticate.

But I'm not sure of the best cleanup on a quick look.  And this is a
simple bugfix.  Maybe we could add some cleanup on top for 4.11.)

--b.

> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  net/sunrpc/svc.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 75f290b..63ca2ea 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -1155,6 +1155,11 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
>  	case SVC_DENIED:
>  		goto err_bad_auth;
>  	case SVC_CLOSE:
> +		/*
> +		 * Makesure authorise svc if progp->pg_authenticate fail,
> +		 * it's harmless if svc_authenticate fail.
> +		 */
> +		svc_authorise(rqstp);
>  		goto close;
>  	case SVC_DROP:
>  		goto dropit;
> -- 
> 2.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 75f290b..63ca2ea 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1155,6 +1155,11 @@  svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
 	case SVC_DENIED:
 		goto err_bad_auth;
 	case SVC_CLOSE:
+		/*
+		 * Makesure authorise svc if progp->pg_authenticate fail,
+		 * it's harmless if svc_authenticate fail.
+		 */
+		svc_authorise(rqstp);
 		goto close;
 	case SVC_DROP:
 		goto dropit;