summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-03-25 17:38:31 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2019-09-13 03:06:14 +0200
commit74983ac20aeafc88d9ceed64a8bf2a9024c488d5 (patch)
treeb36666d741153e2a86f641f109d26e6735514a24 /fs
parentvfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs to use the new mount API (diff)
downloadlinux-74983ac20aeafc88d9ceed64a8bf2a9024c488d5.tar.xz
linux-74983ac20aeafc88d9ceed64a8bf2a9024c488d5.zip
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs_parser.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index 460ea4206fa2..d1930adce68d 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -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: