Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6310951ybi; Wed, 29 May 2019 06:08:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqySfFVgKuG+tPmlK7BR3x2T8MH5RPzRT759T7sPR1gsCzUz/XvMWtgpafb4pJjfmF4xJs7n X-Received: by 2002:a17:902:9f8b:: with SMTP id g11mr134559880plq.199.1559135301787; Wed, 29 May 2019 06:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559135301; cv=none; d=google.com; s=arc-20160816; b=Mqqdji1RNwXgXj/adGV+DJtl8oFclE62/jbyYfNpqw7hAIQbHuXdik7crJc+9KXcb8 pa/7rUwXRjEH8f8bG5KisFV8Nf1yMUM2tHt0JYAp39rPixtwyqr919RC533baypWlX2a +9Wk9WWTPn5MlBDIH1Mn/AXJ+kU4bWcxF8zMpX9UOg4SKnrqHkYMbLu713ORD0yUVIIx U1bt+A/XHKqfb+ATN3x9o2ti6YbSTxh4bJeKHvMU1+HSoR1a8M3zsMZ+Je/SaJmuaGZ3 KQz6m0jZYK1xRPjLc8cKpf1eq8fl4czCTDgrF3xdHYYfs+xBF2UamuAaxzii/MdG9LYy Ai8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject; bh=maHid3IUR8dzilc8ZYgrs3RduNOK7btRaeJgmWOD9Rk=; b=o3RraVLIL8n/zNHkYh6gadCCW55VgT1ahjAF2p0o/5rMX1GuRT/RxfGfYmDrxYUPms tqJDncnvy4CBdB0N/DnenOMMuizTlieW569SWpXULClA1oEHx+KJMfB8czykItHZAMAJ CXL+5wpUJvRhaHWSAWhYsAD79HaZeJTePQT1g7tcRgUnHYhTmzSypyE92NaTG73gKIwp Qa9X0tY/ORQLRremc7/4tkiFE7jtTM8CVfEiktpZ+uDRRdWGpuZoe2hM6e0n+zYlBRkP ffoWkrgVkiIvvoXf5NPIieoQDf9R2ahRmNf9J9FGz+ypCxsv0AKPCcoI7JJAZQyWFrBZ 2s6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si26142560plb.188.2019.05.29.06.07.40; Wed, 29 May 2019 06:08:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbfE2NHi (ORCPT + 99 others); Wed, 29 May 2019 09:07:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5064 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfE2NHi (ORCPT ); Wed, 29 May 2019 09:07:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33D073179B46; Wed, 29 May 2019 13:07:38 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-117-143.phx2.redhat.com [10.3.117.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id C45EC5D982; Wed, 29 May 2019 13:07:37 +0000 (UTC) Subject: Re: [PATCH v2] Fix mountd segfault To: Chuck Lever , linux-nfs@vger.kernel.org References: <20190514150755.12543.64896.stgit@oracle-102.nfsv4bat.org> From: Steve Dickson Message-ID: Date: Wed, 29 May 2019 09:07:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190514150755.12543.64896.stgit@oracle-102.nfsv4bat.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 29 May 2019 13:07:38 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 5/14/19 11:10 AM, Chuck Lever wrote: > After commit 8f459a072f93 ("Remove abuse of ai_canonname") the > ai_canonname field in addrinfo structs returned from > host_reliable_addrinfo() is always NULL. This results in mountd > segfaults when there are netgroups or hostname wildcards in > /etc/exports. > > Add an extra DNS query in check_wildcard() and check_netgroup() to > obtain the client's canonical hostname instead of dereferencing > the NULL pointer. > > Reported-by: Mark Wagner > Fixes: 8f459a072f93 ("Remove abuse of ai_canonname") > Signed-off-by: Chuck Lever Committed... steved. > --- > > Changes since v1: > - Added similar fix for check_netgroup > - Restructured exit/error paths in check_wildcard > > support/export/client.c | 32 +++++++++++++++++++++----------- > 1 file changed, 21 insertions(+), 11 deletions(-) > > diff --git a/support/export/client.c b/support/export/client.c > index a1fba01..ea4f89d 100644 > --- a/support/export/client.c > +++ b/support/export/client.c > @@ -608,24 +608,36 @@ 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; > + int match; > > - if (wildmat(hname, cname)) > - return 1; > + match = 0; > + > + hname = host_canonname(ai->ai_addr); > + if (hname == NULL) > + goto out; > + > + if (wildmat(hname, cname)) { > + match = 1; > + goto out; > + } > > /* See if hname aliases listed in /etc/hosts or nis[+] > * match the requested wildcard */ > hp = gethostbyname(hname); > if (hp != NULL) { > for (ap = hp->h_aliases; *ap; ap++) > - if (wildmat(*ap, cname)) > - return 1; > + if (wildmat(*ap, cname)) { > + match = 1; > + goto out; > + } > } > > - return 0; > +out: > + free(hname); > + return match; > } > > /* > @@ -645,11 +657,9 @@ check_netgroup(const nfs_client *clp, const struct addrinfo *ai) > > match = 0; > > - hname = strdup(ai->ai_canonname); > - if (hname == NULL) { > - xlog(D_GENERAL, "%s: no memory for strdup", __func__); > + hname = host_canonname(ai->ai_addr); > + if (hname == NULL) > goto out; > - } > > /* First, try to match the hostname without > * splitting off the domain */ >