diff options
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/f_fs.c | 23 | ||||
-rw-r--r-- | drivers/usb/gadget/inode.c | 4 |
2 files changed, 18 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 829aba75a6d..a26c43a151f 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -224,8 +224,8 @@ struct ffs_data { /* File permissions, written once when fs is mounted */ struct ffs_file_perms { umode_t mode; - uid_t uid; - gid_t gid; + kuid_t uid; + kgid_t gid; } file_perms; /* @@ -1147,10 +1147,19 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) break; case 3: - if (!memcmp(opts, "uid", 3)) - data->perms.uid = value; + if (!memcmp(opts, "uid", 3)) { + data->perms.uid = make_kuid(current_user_ns(), value); + if (!uid_valid(data->perms.uid)) { + pr_err("%s: unmapped value: %lu\n", opts, value); + return -EINVAL; + } + } else if (!memcmp(opts, "gid", 3)) - data->perms.gid = value; + data->perms.gid = make_kgid(current_user_ns(), value); + if (!gid_valid(data->perms.gid)) { + pr_err("%s: unmapped value: %lu\n", opts, value); + return -EINVAL; + } else goto invalid; break; @@ -1179,8 +1188,8 @@ ffs_fs_mount(struct file_system_type *t, int flags, struct ffs_sb_fill_data data = { .perms = { .mode = S_IFREG | 0600, - .uid = 0, - .gid = 0 + .uid = GLOBAL_ROOT_UID, + .gid = GLOBAL_ROOT_GID, }, .root_mode = S_IFDIR | 0500, }; diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 4bb6d53f2de..76494cabf4e 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1985,8 +1985,8 @@ gadgetfs_make_inode (struct super_block *sb, if (inode) { inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_uid = default_uid; - inode->i_gid = default_gid; + inode->i_uid = make_kuid(&init_user_ns, default_uid); + inode->i_gid = make_kgid(&init_user_ns, default_gid); inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_private = data; |