linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH RFC] mountd: Fix check_wildcard
Date: Tue, 14 May 2019 09:14:58 -0400	[thread overview]
Message-ID: <20190514131458.29602.22688.stgit@oracle-102.nfsv4bat.org> (raw)

After commit 8f459a072f93 ("Remove abuse of ai_canonname") the
ai_canonname field in addrinfo structs returned from
host_reliable_addrinfo() is always NULL. This causes a segfault in
check_wildcard(), breaking wildcarded client names in
/etc/exports.

The proposed solution is to add a DNS query in check_wildcard() to
obtain the client's canonical hostname on which to perform the
wildcard match.

Note that check_netgroup() probably has the same issue.

Reported-by: Mark Wagner <mark@lanfear.net>
Fixes: 8f459a072f93 ("Remove abuse of ai_canonname")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 support/export/client.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index a1fba01..05260ed 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -608,17 +608,23 @@ check_subnetwork(const nfs_client *clp, const struct addrinfo *ai)
 static int
 check_wildcard(const nfs_client *clp, const struct addrinfo *ai)
 {
-	char *cname = clp->m_hostname;
-	char *hname = ai->ai_canonname;
+	char *hname, *cname = clp->m_hostname;
 	struct hostent *hp;
 	char **ap;
 
-	if (wildmat(hname, cname))
+	hname = host_canonname(ai->ai_addr);
+	if (hname == NULL)
+		return 0;
+
+	if (wildmat(hname, cname)) {
+		free(hname);
 		return 1;
+	}
 
 	/* See if hname aliases listed in /etc/hosts or nis[+]
 	 * match the requested wildcard */
 	hp = gethostbyname(hname);
+	free(hname);
 	if (hp != NULL) {
 		for (ap = hp->h_aliases; *ap; ap++)
 			if (wildmat(*ap, cname))


                 reply	other threads:[~2019-05-14 13:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190514131458.29602.22688.stgit@oracle-102.nfsv4bat.org \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /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).