Commit 15121c18 authored by Eric Sandeen's avatar Eric Sandeen Committed by Theodore Ts'o

ext4: Fix optional-arg mount options

We have 2 mount options, "barrier" and "auto_da_alloc" which may or
may not take a 1/0 argument.  This causes the ext4 superblock mount
code to subtract uninitialized pointers and pass the result to
kmalloc, which results in very noisy failures.

Per Ted's suggestion, initialize the args struct so that
we know whether match_token() found an argument for the
option, and skip match_int() if not.

Also, return error (0) from parse_options if we thought
we found an argument, but match_int() Fails.
Reported-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent a1de02dc
...@@ -1229,6 +1229,11 @@ static int parse_options(char *options, struct super_block *sb, ...@@ -1229,6 +1229,11 @@ static int parse_options(char *options, struct super_block *sb,
if (!*p) if (!*p)
continue; 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); token = match_token(p, tokens, args);
switch (token) { switch (token) {
case Opt_bsd_df: case Opt_bsd_df:
...@@ -1518,10 +1523,11 @@ set_qf_format: ...@@ -1518,10 +1523,11 @@ set_qf_format:
clear_opt(sbi->s_mount_opt, BARRIER); clear_opt(sbi->s_mount_opt, BARRIER);
break; break;
case Opt_barrier: case Opt_barrier:
if (match_int(&args[0], &option)) { if (args[0].from) {
set_opt(sbi->s_mount_opt, BARRIER); if (match_int(&args[0], &option))
break; return 0;
} } else
option = 1; /* No argument, default to 1 */
if (option) if (option)
set_opt(sbi->s_mount_opt, BARRIER); set_opt(sbi->s_mount_opt, BARRIER);
else else
...@@ -1594,10 +1600,11 @@ set_qf_format: ...@@ -1594,10 +1600,11 @@ set_qf_format:
set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC);
break; break;
case Opt_auto_da_alloc: case Opt_auto_da_alloc:
if (match_int(&args[0], &option)) { if (args[0].from) {
clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); if (match_int(&args[0], &option))
break; return 0;
} } else
option = 1; /* No argument, default to 1 */
if (option) if (option)
clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment