Skip to content

Commit b9b73f7

Browse files
committed
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>
1 parent 32d639c commit b9b73f7

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎drivers/usb/gadget/f_fs.c‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ struct ffs_data {
220220
/* File permissions, written once when fs is mounted */
221221
struct ffs_file_perms {
222222
umode_t mode;
223-
uid_t uid;
224-
gid_t gid;
223+
kuid_t uid;
224+
kgid_t gid;
225225
} file_perms;
226226

227227
/*
@@ -1143,10 +1143,19 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
11431143
break;
11441144

11451145
case 3:
1146-
if (!memcmp(opts, "uid", 3))
1147-
data->perms.uid = value;
1146+
if (!memcmp(opts, "uid", 3)) {
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+
}
11481153
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+
}
11501159
else
11511160
goto invalid;
11521161
break;
@@ -1175,8 +1184,8 @@ ffs_fs_mount(struct file_system_type *t, int flags,
11751184
struct ffs_sb_fill_data data = {
11761185
.perms = {
11771186
.mode = S_IFREG | 0600,
1178-
.uid = 0,
1179-
.gid = 0
1187+
.uid = GLOBAL_ROOT_UID,
1188+
.gid = GLOBAL_ROOT_GID,
11801189
},
11811190
.root_mode = S_IFDIR | 0500,
11821191
};

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,6 @@ config UIDGID_CONVERTED
932932
depends on NET_9P = n
933933

934934
# Filesystems
935-
depends on USB_FUNCTIONFS = n
936935
depends on DEVTMPFS = n
937936
depends on XENFS = n
938937

0 commit comments

Comments
 (0)