Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1783166ybm; Thu, 23 May 2019 06:44:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqysWHIRq77tofVGMFRC3x5i1PwdvVCbBdFfaSdHa28kAj4PminQgSfxfRbGq4sa2dQxwFTg X-Received: by 2002:a17:90a:21ce:: with SMTP id q72mr1173557pjc.3.1558619060386; Thu, 23 May 2019 06:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558619060; cv=none; d=google.com; s=arc-20160816; b=TuKlFcZCss1/aCY4rl+E46K6JgXmXxSAD7/vd7lwJtgwQ47GVx0Te4rmdgk+KYelmY Q6/xEGWSs6o2j7nC/8k+el4hNnkWXWCrRO0MMB6PRPvDFNkGicuAiCrOC0FdcDIRE+IV jqzRfBFDFY1KiWcimwUsw7rgb4kwryog58HUj2RPsmtPPNiS6DDcuZ8JrKU2pb4zKcVy wpNUng1lrVz4OUfiRmTbng5PW3xtzgEsFa7pvnRYsJnYnbsl3jK6wSeVIghYNpK8Bh0i TwHrskwxvmZA8Tm6I8NtM5fAVwHPegb31Mx3q4Pohg8KxLEoiNfgJyvA++aDlVK7dJrT IR+g== 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=yyWMGyp02pQ/SYBNaRnhVtAyNTMj78Puo5mB171etls=; b=s6K5lkvu/FGfGke2M7fay8qiLbDwJF4Gux8+VUDrdu4TQtETvkIwVrj3dUqzsKvgvK P+nQ7Y7OjYxOV0GL97XO+s7A26xwbvNrXqqT2uf5yOt9PQuj8mIkWo8Dpeu5G4SrDlT5 5WTCoGONzRHv4+xsZxEoR05leBYrw8CkteWdSjP6jE/hQIRZz3+lfswt5W2RHTrhst0F iiiWFsp5tQoKn1St5XCso40LIbaZLMIECucs27UZbB53yNBmuLtsSF/Rw+9xpq48Yul4 Vl69ckigDzAA2ESq+tNbXewnSC3g735+Mu+HXM0PKBsSOsn/ddOrs0T8G72VaDFCWZRh 1HLw== 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 e6si31478288pfe.111.2019.05.23.06.43.57; Thu, 23 May 2019 06:44:20 -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 S1730613AbfEWNnw (ORCPT + 99 others); Thu, 23 May 2019 09:43:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54559 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729698AbfEWNnw (ORCPT ); Thu, 23 May 2019 09:43:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CA749F736 for ; Thu, 23 May 2019 13:43:52 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC4819695; Thu, 23 May 2019 13:43:52 +0000 (UTC) Subject: Re: [PATCH] rpc.mountd: Fix e_hostname and e_uuid leaks reported in bz1711210 To: Nikhil Kshirsagar , linux-nfs@vger.kernel.org References: <1558590454-31741-1-git-send-email-nkshirsa@redhat.com> From: Steve Dickson Message-ID: <0c0b2c96-0701-11e1-9f52-85be8328e251@RedHat.com> Date: Thu, 23 May 2019 09:43:51 -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: <1558590454-31741-1-git-send-email-nkshirsa@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 23 May 2019 13:43:52 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 5/23/19 1:47 AM, Nikhil Kshirsagar wrote: > strdup of exportent uuid and hostname in getexportent() ends up leaking > memory. Free the memory before getexportent() is called again from xtab_read() > > Signed-off-by: Nikhil Kshirsagar Committed... steved. > --- > support/export/xtab.c | 19 ++++++++++++++++++- > support/nfs/exports.c | 15 +++++++++++++-- > 2 files changed, 31 insertions(+), 3 deletions(-) > > diff --git a/support/export/xtab.c b/support/export/xtab.c > index d42eeef..1e1d679 100644 > --- a/support/export/xtab.c > +++ b/support/export/xtab.c > @@ -50,6 +50,14 @@ xtab_read(char *xtab, char *lockfn, int is_export) > while ((xp = getexportent(is_export==0, 0)) != NULL) { > if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) && > !(exp = export_create(xp, is_export!=1))) { > + if(xp->e_hostname) { > + free(xp->e_hostname); > + xp->e_hostname=NULL; > + } > + if(xp->e_uuid) { > + free(xp->e_uuid); > + xp->e_uuid=NULL; > + } > continue; > } > switch (is_export) { > @@ -62,7 +70,16 @@ xtab_read(char *xtab, char *lockfn, int is_export) > if ((xp->e_flags & NFSEXP_FSID) && xp->e_fsid == 0) > v4root_needed = 0; > break; > - } > + } > + if(xp->e_hostname) { > + free(xp->e_hostname); > + xp->e_hostname=NULL; > + } > + if(xp->e_uuid) { > + free(xp->e_uuid); > + xp->e_uuid=NULL; > + } > + > } > endexportent(); > xfunlock(lockid); > diff --git a/support/nfs/exports.c b/support/nfs/exports.c > index 5f4cb95..a7582ca 100644 > --- a/support/nfs/exports.c > +++ b/support/nfs/exports.c > @@ -179,9 +179,20 @@ getexportent(int fromkernel, int fromexports) > } > ee.e_hostname = xstrdup(hostname); > > - if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) > - return NULL; > + if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) { > + if(ee.e_hostname) > + { > + xfree(ee.e_hostname); > + ee.e_hostname=NULL; > + } > + if(ee.e_uuid) > + { > + xfree(ee.e_uuid); > + ee.e_uuid=NULL; > + } > > + return NULL; > + } > /* resolve symlinks */ > if (realpath(ee.e_path, rpath) != NULL) { > rpath[sizeof (rpath) - 1] = '\0'; >