Skip to content

Commit 74983ac

Browse files
dhowellsAl Viro
authored andcommitted
vfs: Make fs_parse() handle fs_param_is_fd-type params better
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>
1 parent f323562 commit 74983ac

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

fs/fs_parser.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,23 @@ int fs_parse(struct fs_context *fc,
204204
goto okay;
205205

206206
case fs_param_is_fd: {
207-
if (param->type != fs_value_is_file)
207+
switch (param->type) {
208+
case fs_value_is_string:
209+
if (!result->has_value)
210+
goto bad_value;
211+
212+
ret = kstrtouint(param->string, 0, &result->uint_32);
213+
break;
214+
case fs_value_is_file:
215+
result->uint_32 = param->dirfd;
216+
ret = 0;
217+
default:
208218
goto bad_value;
209-
goto okay;
219+
}
220+
221+
if (result->uint_32 > INT_MAX)
222+
goto bad_value;
223+
goto maybe_okay;
210224
}
211225

212226
case fs_param_is_blockdev:

0 commit comments

Comments
 (0)