From: NeilBrown <neilb@suse.de>
To: Steve Dickson <steved@redhat.com>,
Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH nfs-utils v2] mount: fix parsing of default options
Date: Mon, 01 Feb 2021 16:00:27 +1100 [thread overview]
Message-ID: <875z3cfklw.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <87lfccfx5t.fsf@notabene.neil.brown.name>
[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]
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 <neilb@suse.de>
---
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);
--
2.30.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]
next prev parent reply other threads:[~2021-02-01 5:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 18:40 [PATCH] mount: parse default values correctly Steve Dickson
2021-01-07 16:03 ` Steve Dickson
2021-01-28 23:39 ` NeilBrown
2021-01-28 23:40 ` [PATCH nfs-utils] mount: fix parsing of default options NeilBrown
2021-02-01 5:00 ` NeilBrown [this message]
2021-02-02 17:00 ` [PATCH nfs-utils v2] " Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875z3cfklw.fsf@notabene.neil.brown.name \
--to=neilb@suse.de \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox