Skip to content

Commit

Permalink
fuse: handle large user and group ID
Browse files Browse the repository at this point in the history
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: Miklos Szeredi <mszeredi@suse.cz>
Cc: stable@vger.kernel.org
  • Loading branch information
Miklos Szeredi committed Jul 7, 2014
1 parent 7b3d8bf commit 233a01f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,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;
Expand All @@ -488,6 +499,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;
Expand All @@ -511,18 +523,18 @@ 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 = make_kuid(current_user_ns(), value);
d->user_id = make_kuid(current_user_ns(), uv);
if (!uid_valid(d->user_id))
return 0;
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 = make_kgid(current_user_ns(), value);
d->group_id = make_kgid(current_user_ns(), uv);
if (!gid_valid(d->group_id))
return 0;
d->group_id_present = 1;
Expand Down

0 comments on commit 233a01f

Please sign in to comment.