From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v3] btrfs: verify max_inline mount parameter
Date: Mon, 26 Feb 2018 10:47:04 +0800 [thread overview]
Message-ID: <20180226024704.15567-1-anand.jain@oracle.com> (raw)
In-Reply-To: <20180215164338.GC10193@twin.jikos.cz>
We aren't verifying the parameter passed to the max_inline mount option.
So we won't fail the mount if a junk value is specified, for example,
-o max_inline=abc. This patch checks if input is valid.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2->v3: Handle parameter with unit, such as 4K. Use memparse() 2nd arg.
v1->v2: use match_int ret value if error
use %u instead of %d for parser
fs/btrfs/super.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 77e0537e1db5..76b58da8d56d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -605,7 +605,14 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
case Opt_max_inline:
num = match_strdup(&args[0]);
if (num) {
- info->max_inline = memparse(num, NULL);
+ char *retptr;
+
+ info->max_inline = memparse(num, &retptr);
+ if (*retptr != '\0') {
+ ret = -EINVAL;
+ kfree(num);
+ goto out;
+ }
kfree(num);
if (info->max_inline) {
--
2.15.0
next prev parent reply other threads:[~2018-02-26 2:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 9:49 [PATCH v2 1/2] btrfs: declare max_inline as u32 Anand Jain
2018-02-13 9:49 ` [PATCH v2 2/2] btrfs: verify max_inline mount parameter Anand Jain
2018-02-13 16:28 ` David Sterba
2018-02-14 17:20 ` Anand Jain
2018-02-15 16:43 ` David Sterba
2018-02-26 2:47 ` Anand Jain [this message]
2018-02-27 15:45 ` [PATCH v3] " David Sterba
2018-03-01 11:51 ` Anand Jain
2018-03-05 21:34 ` David Sterba
2018-02-13 16:28 ` [PATCH v2 1/2] btrfs: declare max_inline as u32 David Sterba
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=20180226024704.15567-1-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/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).