Skip to content

Commit f876df9

Browse files
author
Mike Snitzer
committed
dm verity: fix verity_parse_opt_args parsing
Commit df326e7 ("dm verity: allow optional args to alter primary args handling") introduced a bug where verity_parse_opt_args() wouldn't properly shift past an optional argument's additional params (by ignoring them). Fix this by avoiding returning with error if an unknown argument is encountered when @only_modifier_opts=true is passed to verity_parse_opt_args(). In practice this regressed the cryptsetup testsuite's FEC testing because unknown optional arguments were encountered, wherey short-circuiting ever testing FEC mode. With this fix all of the cryptsetup testsuite's verity FEC tests pass. Fixes: df326e7 ("dm verity: allow optional args to alter primary args handling") Reported-by: Milan Broz <gmazyland@gmail.com>> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 8c22816 commit f876df9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/md/dm-verity-target.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
10521052
struct dm_verity_sig_opts *verify_args,
10531053
bool only_modifier_opts)
10541054
{
1055-
int r;
1055+
int r = 0;
10561056
unsigned argc;
10571057
struct dm_target *ti = v->ti;
10581058
const char *arg_name;
@@ -1122,8 +1122,18 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
11221122
if (r)
11231123
return r;
11241124
continue;
1125+
1126+
} else if (only_modifier_opts) {
1127+
/*
1128+
* Ignore unrecognized opt, could easily be an extra
1129+
* argument to an option whose parsing was skipped.
1130+
* Normal parsing (@only_modifier_opts=false) will
1131+
* properly parse all options (and their extra args).
1132+
*/
1133+
continue;
11251134
}
11261135

1136+
DMERR("Unrecognized verity feature request: %s", arg_name);
11271137
ti->error = "Unrecognized verity feature request";
11281138
return -EINVAL;
11291139
} while (argc && !r);

0 commit comments

Comments
 (0)