linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] mountd: Fix check_wildcard
@ 2019-05-14 13:14 Chuck Lever
  0 siblings, 0 replies; only message in thread
From: Chuck Lever @ 2019-05-14 13:14 UTC (permalink / raw)
  To: linux-nfs

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))


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-14 13:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14 13:14 [PATCH RFC] mountd: Fix check_wildcard Chuck Lever

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).