userns: Convert usb functionfs to use kuid/kgid where appropriate
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 14 Jun 2012 08:19:23 +0000 (01:19 -0700)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 21 Sep 2012 10:12:51 +0000 (03:12 -0700)
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>
drivers/usb/gadget/f_fs.c
init/Kconfig

index 8adc79d1b40277ac15092a53bac28749627c60cf..f9ee4e08a4a8c4a03562b94ccf694256a3e0e800 100644 (file)
@@ -220,8 +220,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;
 
        /*
@@ -1143,10 +1143,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;
@@ -1175,8 +1184,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,
        };
index 633bde28c8ce05089a59d04218a943dbc63123ca..e7e0cc15ef68a75e859719cd28864decc184cd92 100644 (file)
@@ -932,7 +932,6 @@ config UIDGID_CONVERTED
        depends on NET_9P = n
 
        # Filesystems
-       depends on USB_FUNCTIONFS = n
        depends on DEVTMPFS = n
        depends on XENFS = n