aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_fs.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-06-14 04:19:23 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-09-21 06:12:51 -0400
commitb9b73f7c4d45d69289aa16620b04430068dd3941 (patch)
tree4556d632d3958b45e30de3ace80ef688fc216850 /drivers/usb/gadget/f_fs.c
parent32d639c66e04149d490093f8b4b49cb922bfe294 (diff)
userns: Convert usb functionfs to use kuid/kgid where appropriate
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Felipe Balbi <balbi@ti.com> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'drivers/usb/gadget/f_fs.c')
-rw-r--r--drivers/usb/gadget/f_fs.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 8adc79d1b402..f9ee4e08a4a8 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -220,8 +220,8 @@ struct ffs_data {
220 /* File permissions, written once when fs is mounted */ 220 /* File permissions, written once when fs is mounted */
221 struct ffs_file_perms { 221 struct ffs_file_perms {
222 umode_t mode; 222 umode_t mode;
223 uid_t uid; 223 kuid_t uid;
224 gid_t gid; 224 kgid_t gid;
225 } file_perms; 225 } file_perms;
226 226
227 /* 227 /*
@@ -1143,10 +1143,19 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
1143 break; 1143 break;
1144 1144
1145 case 3: 1145 case 3:
1146 if (!memcmp(opts, "uid", 3)) 1146 if (!memcmp(opts, "uid", 3)) {
1147 data->perms.uid = value; 1147 data->perms.uid = make_kuid(current_user_ns(), value);
1148 if (!uid_valid(data->perms.uid)) {
1149 pr_err("%s: unmapped value: %lu\n", opts, value);
1150 return -EINVAL;
1151 }
1152 }
1148 else if (!memcmp(opts, "gid", 3)) 1153 else if (!memcmp(opts, "gid", 3))
1149 data->perms.gid = value; 1154 data->perms.gid = make_kgid(current_user_ns(), value);
1155 if (!gid_valid(data->perms.gid)) {
1156 pr_err("%s: unmapped value: %lu\n", opts, value);
1157 return -EINVAL;
1158 }
1150 else 1159 else
1151 goto invalid; 1160 goto invalid;
1152 break; 1161 break;
@@ -1175,8 +1184,8 @@ ffs_fs_mount(struct file_system_type *t, int flags,
1175 struct ffs_sb_fill_data data = { 1184 struct ffs_sb_fill_data data = {
1176 .perms = { 1185 .perms = {
1177 .mode = S_IFREG | 0600, 1186 .mode = S_IFREG | 0600,
1178 .uid = 0, 1187 .uid = GLOBAL_ROOT_UID,
1179 .gid = 0 1188 .gid = GLOBAL_ROOT_GID,
1180 }, 1189 },
1181 .root_mode = S_IFDIR | 0500, 1190 .root_mode = S_IFDIR | 0500,
1182 }; 1191 };