Linux-NFS Archive on lore.kernel.org
 help / Atom feed
* [PATCH RFC] mountd: Fix check_wildcard
@ 2019-05-14 13:14 Chuck Lever
  0 siblings, 0 replies; 1+ messages 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	[flat|nested] 1+ messages in thread

only message in thread, back to index

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

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org linux-nfs@archiver.kernel.org
	public-inbox-index linux-nfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox