linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sunrpc: on successful gss error pipe write, don't return error (try #3)
@ 2009-12-18 21:23 Jeff Layton
  2009-12-18 21:30 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2009-12-18 21:23 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. In the event of other
errors, we generally want the initiating task to retry the upcall so
we set msg.errno to -EAGAIN. An unexpected error code here is a bug
however, so BUG() in that case.

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

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 3c3c50f..66cb89c 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -644,7 +644,22 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 	p = gss_fill_context(p, end, ctx, gss_msg->auth->mech);
 	if (IS_ERR(p)) {
 		err = PTR_ERR(p);
-		gss_msg->msg.errno = (err == -EAGAIN) ? -EAGAIN : -EACCES;
+		switch (err) {
+		case -EACCES:
+			gss_msg->msg.errno = err;
+			err = mlen;
+			break;
+		case -EFAULT:
+		case -ENOMEM:
+		case -EINVAL:
+		case -ENOSYS:
+			gss_msg->msg.errno = -EAGAIN;
+			break;
+		default:
+			printk(KERN_CRIT "%s: bad return from "
+				"gss_fill_context: %ld\n", __func__, err);
+			BUG();
+		}
 		goto err_release_msg;
 	}
 	gss_msg->ctx = gss_get_ctx(ctx);
-- 
1.6.5.2

_______________________________________________
NFSv4 mailing list
NFSv4@linux-nfs.org
http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4

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

* Re: [PATCH] sunrpc: on successful gss error pipe write, don't return error (try #3)
  2009-12-18 21:23 [PATCH] sunrpc: on successful gss error pipe write, don't return error (try #3) Jeff Layton
@ 2009-12-18 21:30 ` Trond Myklebust
  0 siblings, 0 replies; 2+ messages in thread
From: Trond Myklebust @ 2009-12-18 21:30 UTC (permalink / raw)
  To: Jeff Layton; +Cc: linux-nfs, nfsv4

On Fri, 2009-12-18 at 16:23 -0500, Jeff Layton wrote: 
> 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. In the event of other
> errors, we generally want the initiating task to retry the upcall so
> we set msg.errno to -EAGAIN. An unexpected error code here is a bug
> however, so BUG() in that case.

That looks good. I'll apply it after the two other fixes.

Trond

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-18 21:23 [PATCH] sunrpc: on successful gss error pipe write, don't return error (try #3) Jeff Layton
2009-12-18 21:30 ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).