All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sunrpc: on successful gss error pipe write, don't return error
@ 2009-12-18 13:56 Jeff Layton
  2009-12-18 14:11 ` Trond Myklebust
  0 siblings, 1 reply; 13+ messages in thread
From: Jeff Layton @ 2009-12-18 13:56 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, nfsv4

When handling the gssd downcall, the kernel should distinguish between a
successful downcall that contains an error code and a failed downcall
(i.e. where the parsing failed or some other sort of problem occurred).

In the former case, gss_pipe_downcall should be returning the number of
bytes written to the pipe instead of an error.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 net/sunrpc/auth_gss/auth_gss.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 3c3c50f..03cc5a4 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -184,7 +184,8 @@ gss_alloc_context(void)
 
 #define GSSD_MIN_TIMEOUT (60 * 60)
 static const void *
-gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct gss_api_mech *gm)
+gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx,
+		 struct gss_api_mech *gm, ssize_t *downcall_err)
 {
 	const void *q;
 	unsigned int seclen;
@@ -208,6 +209,7 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct
 	if (ctx->gc_win == 0) {
 		/* in which case, p points to  an error code which we ignore */
 		p = ERR_PTR(-EACCES);
+		*downcall_err = -EACCES;
 		goto err;
 	}
 	/* copy the opaque wire context */
@@ -641,10 +643,21 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 	list_del_init(&gss_msg->list);
 	spin_unlock(&inode->i_lock);
 
-	p = gss_fill_context(p, end, ctx, gss_msg->auth->mech);
+	err = 0;
+	p = gss_fill_context(p, end, ctx, gss_msg->auth->mech, &err);
 	if (IS_ERR(p)) {
-		err = PTR_ERR(p);
-		gss_msg->msg.errno = (err == -EAGAIN) ? -EAGAIN : -EACCES;
+		/*
+		 * a non-zero downcall_err indicates that downcall write was
+		 * OK, but contained a zero gc_win (and hence an error code).
+		 */
+		if (err) {
+			gss_msg->msg.errno = err;
+			err = mlen;
+		} else {
+			err = PTR_ERR(p);
+			gss_msg->msg.errno = (err == -EAGAIN) ?
+							-EAGAIN : -EACCES;
+		}
 		goto err_release_msg;
 	}
 	gss_msg->ctx = gss_get_ctx(ctx);
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-12-18 20:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-18 13:56 [PATCH] sunrpc: on successful gss error pipe write, don't return error Jeff Layton
2009-12-18 14:11 ` Trond Myklebust
2009-12-18 14:39   ` Jeff Layton
     [not found]     ` <20091218093912.1c426ad6-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2009-12-18 14:47       ` Trond Myklebust
2009-12-18 15:12         ` Trond Myklebust
2009-12-18 15:37           ` Jeff Layton
     [not found]             ` <20091218103723.38510cce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2009-12-18 18:30               ` Trond Myklebust
2009-12-18 19:14                 ` Jeff Layton
2009-12-18 19:42                   ` Trond Myklebust
2009-12-18 15:25         ` Jeff Layton
2009-12-18 16:25           ` Jeff Layton
2009-12-18 19:33           ` Trond Myklebust
2009-12-18 20:14             ` Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.