Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp454685pxb; Tue, 2 Feb 2021 09:07:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxZRwYOn5DS/wieV95f9haOT2vIxo47kql25kXfCtPnTn8HRJn5s30yfj4fFR+BONVW6IY X-Received: by 2002:a17:906:8292:: with SMTP id h18mr2401534ejx.342.1612285634280; Tue, 02 Feb 2021 09:07:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612285634; cv=none; d=google.com; s=arc-20160816; b=v24dvXwa1PLs1nmQiSS8cfk4VuA8QNvZdMrOYFAmvX4HuW062rAbyrniH4UPsENLkG pRplQYYVSjYMfyB4YBaS5yQi3e+/l7NChl1hm2C+c8le6thKBtQCoQDtqVqCwNS2naor kiUJLiRpTUoTNaj/4OINzKneZona/X6BPF1unT6FLeT4zDMnwKTbjaBglgpEuzGSC03D +muZBxqwt2m+PbPFUEi6PRFYDFJLJQDBKsbzRIzMW7fbXHehNghO2ihui6nSHvceU+1D Z1yHOzRqzzVAjS94Syezoia2CEt4XK8Zb4iY6mH4+ug5RQXuY4CnrmpII6PAYJ4jGDWn wNQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=LqPjowFOIhHHzFKRXTk+xJ9T1CMz1/doRKVSIXtmAf4=; b=qL2OwGvCLvxemdN3tl3iDMPUvHpCqizGmaLRcoIuVZT1IdiLf8VhTB4N4Ci2FfpLfW pQZmz6oOQYuvMGVFtIwVm5FMYGYBoyrsd3PerpuJRphO48fimCmzhFyS59uVln3Qpvac XZ0ccF9kB6EaXdsDz90cFmRbAo3na3xu76FwhX/2pF0ww8leNJDA0M8Z7hBrn6W9km3j td8lNFDe+aSYiJnm4vNH63W4Eyc1OxoH3U+BqBYyz2c2myn6BO8XNum7Y19oG9m/syBd ZE+zflzfflgabAjbEXCWCVrselSNgq2syqGzgsBsa+LEGNYGYDtBO7Pox2T8OKQ6Rnkz xr3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rfc3diGi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx2si11892577ejb.526.2021.02.02.09.06.39; Tue, 02 Feb 2021 09:07:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rfc3diGi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237170AbhBBREd (ORCPT + 99 others); Tue, 2 Feb 2021 12:04:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27565 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236318AbhBBRAv (ORCPT ); Tue, 2 Feb 2021 12:00:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LqPjowFOIhHHzFKRXTk+xJ9T1CMz1/doRKVSIXtmAf4=; b=Rfc3diGilomWUNPFmyC3fFFc/L6KiArjheswMUcvpA8Rmj28tfR8iaBbG1g3f3unV71r7P tryxExBOGYHGQoCWEHwtV+qVfagSyWa+aO7pnA7Ag7KIArjj/yLCbZ6U6rr52mBMPuRJfm rwRvX1I0Nn19YH49PgCKySrrrEEcDN4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-Qgg8fp4dORaQpbvmK-sJ0A-1; Tue, 02 Feb 2021 11:59:21 -0500 X-MC-Unique: Qgg8fp4dORaQpbvmK-sJ0A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 324DB804004; Tue, 2 Feb 2021 16:59:20 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-114-82.phx2.redhat.com [10.3.114.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id E00625C1CF; Tue, 2 Feb 2021 16:59:19 +0000 (UTC) Subject: Re: [PATCH nfs-utils v2] mount: fix parsing of default options To: NeilBrown , Linux NFS Mailing list References: <20210106184028.150925-1-steved@redhat.com> <87o8h8fx7a.fsf@notabene.neil.brown.name> <87lfccfx5t.fsf@notabene.neil.brown.name> <875z3cfklw.fsf@notabene.neil.brown.name> From: Steve Dickson Message-ID: <6a5fc99d-90e7-b58b-7650-d1d294cad6ef@RedHat.com> Date: Tue, 2 Feb 2021 12:00:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <875z3cfklw.fsf@notabene.neil.brown.name> 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.16 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 2/1/21 12:00 AM, NeilBrown wrote: > > A recent patch to change configfile.c to use parse_opt.c contained code > which was intended to remove all "default*" options from the list before > that could be passed to the kernel. This code didn't work, so default* > options WERE passed to the kernel, and the kernel complained and failed > the mount attempt. > > A more recent patch attempted to fix this by not including the > "default*" options in the option list at all. This resulting in > global-default defaults over-riding per-mount or per-server defaults. > > This patch reverse the "more recent" patch, and fixes the original patch > by providing correct code to remove all "default*" options before the > kernel can see them. > > Fixes: 88c22f924f1b ("mount: convert configfile.c to use parse_opt.c") > Fixes: 8142542bda28 ("mount: parse default values correctly") > Signed-off-by: NeilBrown Committed.... (tag: nfs-utils-2-5-3-rc5) steved. > --- > > I realized that po_remove_all() could free 'ptr' and then compare it > against the next option, which would have undefined results. > So best to strdup and free it. > > > utils/mount/configfile.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c > index e865998dd5a9..3d3684efa186 100644 > --- a/utils/mount/configfile.c > +++ b/utils/mount/configfile.c > @@ -277,10 +277,9 @@ conf_parse_mntopts(char *section, char *arg, struct mount_options *options) > } > if (buf[0] == '\0') > continue; > - if (default_value(buf)) > - continue; > > po_append(options, buf); > + default_value(buf); > } > conf_free_list(list); > } > @@ -335,7 +334,11 @@ char *conf_get_mntopts(char *spec, char *mount_point, > * Strip out defaults, which have already been handled, > * then join the rest and return. > */ > - po_remove_all(options, "default"); > + while (po_contains_prefix(options, "default", &ptr, 0) == PO_FOUND) { > + ptr = strdup(ptr); > + po_remove_all(options, ptr); > + free(ptr); > + } > > po_join(options, &mount_opts); > po_destroy(options); >