Skip to content

Commit

Permalink
vfs: Make fs_parse() handle fs_param_is_fd-type params better
Browse files Browse the repository at this point in the history
Make fs_parse() handle fs_param_is_fd-type parameters that are passed a
string by converting it to an integer (in addition to handling direct fd
specification).

Also range check the integer.

[fix from  Yin Fengwei folded]

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
dhowells authored and Al Viro committed Sep 13, 2019
1 parent f323562 commit 74983ac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions fs/fs_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,23 @@ int fs_parse(struct fs_context *fc,
goto okay;

case fs_param_is_fd: {
if (param->type != fs_value_is_file)
switch (param->type) {
case fs_value_is_string:
if (!result->has_value)
goto bad_value;

ret = kstrtouint(param->string, 0, &result->uint_32);
break;
case fs_value_is_file:
result->uint_32 = param->dirfd;
ret = 0;
default:
goto bad_value;
goto okay;
}

if (result->uint_32 > INT_MAX)
goto bad_value;
goto maybe_okay;
}

case fs_param_is_blockdev:
Expand Down

0 comments on commit 74983ac

Please sign in to comment.