linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: steved@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] Revert "mountd: handle allocation failures in auth_unix_ip upcall"
Date: Tue, 27 Nov 2012 16:31:27 -0500	[thread overview]
Message-ID: <20121127213127.GH27142@fieldses.org> (raw)
In-Reply-To: <20121126225116.GE18186@fieldses.org>

On Mon, Nov 26, 2012 at 05:51:16PM -0500, J. Bruce Fields wrote:
> On Mon, Nov 26, 2012 at 05:38:49PM -0500, Chuck Lever wrote:
> > What exactly is the problem with the current code?
> > 
> > client_resolve() can return a NULL in some cases.  Why is it OK to
> > pass a NULL "ai" to client_compose() ?  Looks like that can result in
> > a mountd segfault.
> 
> Bah, I thought I'd checked this and found it was prepared to handle
> that, but no:
> 
> 	client_check->check_wildcard()
> 
> looks like it can oops.

Right, so the real problem is just that we're skipping the downcall on
failure instead of responding with a negative cache entry.  Thus we're
leaving the client hanging instead of returning an error.

So, I suppose we should do the below, based on steved's suggestion
(compiled, otherwise untested).

--b.

commit dfb31d861261c8461a2dc4fb7e8823f5169a9079
Author: J. Bruce Fields <bfields@redhat.com>
Date:   Tue Nov 27 16:10:41 2012 -0500

    mountd: auth_unix_ip should downcall on error to prevent hangs
    
    Since bf6a4febaa78bf188896b7b5b02c46562dd08b70 "mountd: handle
    allocation failures in auth_unix_ip upcall", a failure to map the
    address of an incoming client to a name could result in a hang.
    
    We should be responding with an error in the case, not just skipping the
    downcall and leaving everybody hanging.
    
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index e950ec6..c13f305 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -109,12 +109,10 @@ static void auth_unix_ip(FILE *f)
 		struct addrinfo *ai = NULL;
 
 		ai = client_resolve(tmp->ai_addr);
-		if (ai == NULL)
-			goto out;
-		client = client_compose(ai);
-		freeaddrinfo(ai);
-		if (!client)
-			goto out;
+		if (ai) {
+			client = client_compose(ai);
+			freeaddrinfo(ai);
+		}
 	}
 	qword_print(f, "nfsd");
 	qword_print(f, ipaddr);
@@ -127,7 +125,6 @@ static void auth_unix_ip(FILE *f)
 	xlog(D_CALL, "auth_unix_ip: client %p '%s'", client, client?client: "DEFAULT");
 
 	free(client);
-out:
 	freeaddrinfo(tmp);
 
 }

  parent reply	other threads:[~2012-11-27 21:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 22:03 [PATCH] Revert "mountd: handle allocation failures in auth_unix_ip upcall" J. Bruce Fields
2012-11-26 22:05 ` Chuck Lever
2012-11-26 22:15   ` J. Bruce Fields
2012-11-26 22:38     ` Chuck Lever
2012-11-26 22:51       ` J. Bruce Fields
2012-11-26 23:10         ` Chuck Lever
2012-11-27 14:23         ` Steve Dickson
2012-11-27 21:31         ` J. Bruce Fields [this message]
2012-11-27 21:33           ` Chuck Lever
2012-11-28 14:39           ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121127213127.GH27142@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).