Commit 58b54664 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Ben Hutchings

fuse: handle large user and group ID

commit 233a01fa upstream.

If the number in "user_id=N" or "group_id=N" mount options was larger than
INT_MAX then fuse returned EINVAL.

Fix this to handle all valid uid/gid values.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
[bwh: Backported to 3.2: no user namespace conversion]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 38f8813c
......@@ -437,6 +437,17 @@ static const match_table_t tokens = {
{OPT_ERR, NULL}
};
static int fuse_match_uint(substring_t *s, unsigned int *res)
{
int err = -ENOMEM;
char *buf = match_strdup(s);
if (buf) {
err = kstrtouint(buf, 10, res);
kfree(buf);
}
return err;
}
static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
{
char *p;
......@@ -447,6 +458,7 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
while ((p = strsep(&opt, ",")) != NULL) {
int token;
int value;
unsigned uv;
substring_t args[MAX_OPT_ARGS];
if (!*p)
continue;
......@@ -470,16 +482,16 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
break;
case OPT_USER_ID:
if (match_int(&args[0], &value))
if (fuse_match_uint(&args[0], &uv))
return 0;
d->user_id = value;
d->user_id = uv;
d->user_id_present = 1;
break;
case OPT_GROUP_ID:
if (match_int(&args[0], &value))
if (fuse_match_uint(&args[0], &uv))
return 0;
d->group_id = value;
d->group_id = uv;
d->group_id_present = 1;
break;
......
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