Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3558049pxb; Sun, 31 Jan 2021 21:01:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3AoXyXzVknCqtI0u9wwjmfWBtGpoZMlCSigsjHc4Lnj9LQD7WKl/TT/+3iA6S1vQnIW8Z X-Received: by 2002:a05:6402:5206:: with SMTP id s6mr16804303edd.92.1612155715109; Sun, 31 Jan 2021 21:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612155715; cv=none; d=google.com; s=arc-20160816; b=tvI9ZJzzhN9SHFctMohC8Nzx1fvx3WV8HMQvkkCpOlQ25+K8emTkTW/qCarAKgqwDe pfWr0OpEti+lDnkFyoF1PxLeWJ4gCP0ZzXQrnrDnLN9XINCsJxNWvNo4RCuTCrPqCsVX c/tTLLQV7aKAv8NjRSlymEELDOx1/OQDnGdRlSKDXb4hPd3YmHXXPaYQi9Am+6olHKxc IDWUI2I19HANLu5aDkbuooS8cGaYWyfwd1N75p1oRaEiBCxCPcqxlZufnHZChUgOpPSD dxeqo3P71HkDgVdOtdqAv09SPbsexyYlWf8BdOigfvOKaMBm53d5OnFTnltiRYnKiD4Y f3xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:references:in-reply-to :subject:date:to:from; bh=bqIRDm15He3bZEFDVMAXw7GHwyGvCRAuqIAj+EnmOnY=; b=Zh7FLfuON7/Pqmv9E83KjmHx3ijE1Lbo+ltQjJROyFT/ZAprPb5IrwnM6XckvdiOTq 62Vi4Q7d70U6uLSOohIxEfw3XRdFLoOBD944rz4oCMTYkfxzwrVcikMHTjXtjSlq5wdv qBpd7BUOzC2tq0EFDMCVqUVmFh4jCWTNfKU+9uIELNZ48ukbXyoYpBRnTwRH9nEZVLwp +A0MqUWXkOgX85NB8imniJRYuKA2WZj1qF1hGzg9LVtb+xe8LXFVBpvLth1Y/LVTJDvk yxrotXT71LKSJQHOxPk2W28GzS7y/Of+EYJVTquNbkODLSQubgghnI+u1X6cpl8r0Dtj VRNw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si9973082ejj.440.2021.01.31.21.01.16; Sun, 31 Jan 2021 21:01:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbhBAFBQ (ORCPT + 99 others); Mon, 1 Feb 2021 00:01:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:50680 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbhBAFBO (ORCPT ); Mon, 1 Feb 2021 00:01:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4CADEAC45; Mon, 1 Feb 2021 05:00:32 +0000 (UTC) From: NeilBrown To: Steve Dickson , Linux NFS Mailing list Date: Mon, 01 Feb 2021 16:00:27 +1100 Subject: [PATCH nfs-utils v2] mount: fix parsing of default options In-Reply-To: <87lfccfx5t.fsf@notabene.neil.brown.name> References: <20210106184028.150925-1-steved@redhat.com> <87o8h8fx7a.fsf@notabene.neil.brown.name> <87lfccfx5t.fsf@notabene.neil.brown.name> Message-ID: <875z3cfklw.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 =2D-- 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 =2D-- a/utils/mount/configfile.c +++ b/utils/mount/configfile.c @@ -277,10 +277,9 @@ conf_parse_mntopts(char *section, char *arg, struct mo= unt_options *options) } if (buf[0] =3D=3D '\0') continue; =2D if (default_value(buf)) =2D continue; =20 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. */ =2D po_remove_all(options, "default"); + while (po_contains_prefix(options, "default", &ptr, 0) =3D=3D PO_FOUND) { + ptr =3D strdup(ptr); + po_remove_all(options, ptr); + free(ptr); + } =20 po_join(options, &mount_opts); po_destroy(options); =2D-=20 2.30.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJCBAEBCAAsFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAmAXiusOHG5laWxiQHN1 c2UuZGUACgkQOeye3VZigbkxAhAAi9v0Jdv1NzjBZmhlYle6KYL51M62ZWgJfDmG WNnm9V/J/EoQBorKsVmqLtfEQvz7+hrUvJQSmww5Q7y1AFtBYOZX0ZqEMTN0742X 90LTrymjCUt+P6JwZrFgDyuTHZgyJRyNB10YB/+FGVf5zH8+P6jcxrYDxmjssuRk 3I2cMWyIh18F0vepAp5WVV8sp4/aw5JyOrzhb+KEUr7wqYxfzibI13HKZy8s4Umv j1ILaKdq6KKlwKqp+upzZc8gIdOaxTOXWQNfNCv9w2Dl/jCXrVaUAuAmI4ORVDj6 8PqEaurWLlpL8otSimBd/ik4Ua6fjfTVs4GqN5V3J4n24f1aUDRmqSt3XZbd2umW l72vTpHixxX8IFTwbKo18hX89UpjyeZgIGjUAWM7NqmQgngRXbrEtBBYkGu0O0gn lqLXe2Qd4LUMdSGlaB2JnG+TNkQ8PaLFlAZKQRv5zFGn1bvjnIwTz+duaZWuZO5j IFvNqU6n0Oe4nYDIUK8Z4b4pgrw7HarHAwVvkrotr+74QSU+1jxMtmk8ilKkh4jI aHXl4Zaf1i49uPNeZYSlYRcW+z4FbyRyDBXkO9HXZR68xMk6IyW8lOJR7HUtp+s2 M0DDxtctbO5wdf5g3qyZrUjSeD1stCix1LIfEfOP5IEkY+pIYzR2mWz/8TWS1zwd 9SXCUpM= =l9QY -----END PGP SIGNATURE----- --=-=-=--