From: Vasiliy Kulikov <segoon@openwall.com>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-kernel@vger.kernel.org,
Andrea Arcangeli <aarcange@redhat.com>,
Rik van Riel <riel@redhat.com>, Nick Piggin <npiggin@kernel.dk>,
Eric Dumazet <eric.dumazet@gmail.com>,
Pavel Emelyanov <xemul@parallels.com>,
David Chinner <david@fromorbit.com>,
containers@lists.linux-foundation.org,
Hugh Dickins <hughd@google.com>,
James Bottomley <JBottomley@parallels.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] parse options in the vfs level
Date: Sun, 14 Aug 2011 19:39:31 +0400 [thread overview]
Message-ID: <20110814153930.GA3996@albatros> (raw)
In-Reply-To: <1313334832-1150-5-git-send-email-glommer@parallels.com>
Hi Glauber,
On Sun, Aug 14, 2011 at 19:13 +0400, Glauber Costa wrote:
> +/**
> + * Generic option parsing for the VFS.
> + *
> + * Since most of the filesystems already do their own option parsing, and with
> + * very few code shared between them, this function strips out any options that
> + * we succeed in parsing ourselves. Passing them forward would just give the
> + * underlying fs an option it does not expect, leading it to fail.
> + *
> + * We don't yet have a pointer to the super block as well, since this is
> + * pre-mount. We accumulate in struct vfs_options whatever data we collected,
> + * and act on it later.
> + */
> +static int vfs_parse_options(char *options, struct vfs_options *ops)
> +{
> + substring_t args[MAX_OPT_ARGS];
> + int option;
> + char *p;
> + char *opt;
> + char *start = NULL;
> + int ret;
> +
> + if (!options)
> + return 0;
> +
> + opt = kstrdup(options, GFP_KERNEL);
> + if (!opt)
> + return 1;
> +
> + ret = 1;
> +
> + start = opt;
> + while ((p = strsep(&opt, ",")) != NULL) {
> + int token;
> + if (!*p)
> + continue;
> +
> + /*
> + * Initialize args struct so we know whether arg was
> + * found; some options take optional arguments.
> + */
> + args[0].to = args[0].from = 0;
> + token = match_token(p, tokens, args);
> + switch (token) {
> + case 1:
> + if (!args[0].from)
> + break;
> +
> + if (match_int(&args[0], &option))
> + break;
What if there are 2 passed options and the second fails?
mount -o vfs_dcache_size=XXX,vfs_dcache_size=CRAP <dev> <mntpoint>
In this case you leave the second option and pass it to the fs option
parser (as you already set ret=0), which is wrong. I think you should
explicitly return 1 where you know the option is related to VFS, but you
failed to parse it. It would look even simplier than current code.
(Yes, this is a rare situation, but I can imagine some program that
automatically adds mount options to the existing list and passes it to
mount.)
> + if (option < DCACHE_MIN_SIZE) {
> + printk(KERN_INFO "dcache size %d smaller than "
> + "minimum (%d)\n", option, DCACHE_MIN_SIZE);
> + option = DCACHE_MIN_SIZE;
> + }
> +
> + ops->vfs_dcache_size = option;
> +
> + /*
> + * The actual filesystems don't expect any option
> + * they don't understand to be received in the option
> + * string. So we strip off anything we processed, and
> + * give them a clean options string.
> + */
> + ret = 0;
> + if (!opt) /* it is the last option listed */
> + *(options + (p - start)) = '\0';
> + else
> + strcpy(options + (p - start), opt);
> + break;
> + default:
> + ret = 0;
> + break;
> + }
> + }
> +
> + kfree(start);
> + return ret;
> +}
Thanks,
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
next prev parent reply other threads:[~2011-08-14 15:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-14 15:13 [PATCH v3 0/4] Per-container dcache limitation Glauber Costa
[not found] ` <1313334832-1150-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-08-14 15:13 ` [PATCH v3 1/4] factor out single-shrinker code Glauber Costa
2011-08-15 6:43 ` Dave Chinner
2011-08-14 15:13 ` [PATCH v3 2/4] Keep nr_dentry per super block Glauber Costa
2011-08-14 17:38 ` Eric Dumazet
2011-08-14 15:13 ` [PATCH v3 3/4] limit nr_dentries per superblock Glauber Costa
2011-08-15 7:03 ` Dave Chinner
2011-08-15 7:12 ` Pekka Enberg
2011-08-15 10:46 ` Dave Chinner
2011-08-15 10:58 ` Pekka Enberg
2011-08-15 11:05 ` Pavel Emelyanov
2011-08-15 11:14 ` Pekka Enberg
2011-08-15 11:32 ` Pavel Emelyanov
2011-08-15 11:55 ` Pekka Enberg
2011-08-15 12:12 ` Pavel Emelyanov
2011-08-15 12:23 ` Pekka Enberg
2011-08-15 12:37 ` Pavel Emelyanov
2011-08-16 2:11 ` Dave Chinner
2011-08-14 15:13 ` [PATCH v3 4/4] parse options in the vfs level Glauber Costa
2011-08-14 15:39 ` Vasiliy Kulikov [this message]
2011-08-15 0:03 ` Glauber Costa
2011-08-15 7:09 ` Dave Chinner
2011-08-24 2:19 ` Glauber Costa
2011-08-17 5:43 ` [PATCH v3 0/4] Per-container dcache limitation Dave Chinner
2011-08-17 18:44 ` Glauber Costa
2011-08-18 1:27 ` Dave Chinner
2011-08-22 11:42 ` Glauber Costa
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=20110814153930.GA3996@albatros \
--to=segoon@openwall.com \
--cc=JBottomley@parallels.com \
--cc=aarcange@redhat.com \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=david@fromorbit.com \
--cc=eric.dumazet@gmail.com \
--cc=glommer@parallels.com \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@kernel.dk \
--cc=riel@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.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;
as well as URLs for NNTP newsgroup(s).