userns: Make the airo wireless driver use kuids for proc uids and gids
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 10 Feb 2012 22:01:03 +0000 (14:01 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 15 Aug 2012 04:55:31 +0000 (21:55 -0700)
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
drivers/net/wireless/airo.c
init/Kconfig

index f9f15bb3f03a8b0df468f954af8b234123141caa..c586f78c307ff82e8f4e2b2eec6a6d7035547c80 100644 (file)
@@ -232,8 +232,10 @@ static int adhoc;
 
 static int probe = 1;
 
+static kuid_t proc_kuid;
 static int proc_uid /* = 0 */;
 
+static kgid_t proc_kgid;
 static int proc_gid /* = 0 */;
 
 static int airo_perm = 0555;
@@ -4499,78 +4501,79 @@ struct proc_data {
 static int setup_proc_entry( struct net_device *dev,
                             struct airo_info *apriv ) {
        struct proc_dir_entry *entry;
+
        /* First setup the device directory */
        strcpy(apriv->proc_name,dev->name);
        apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm,
                                            airo_entry);
        if (!apriv->proc_entry)
                goto fail;
-       apriv->proc_entry->uid = proc_uid;
-       apriv->proc_entry->gid = proc_gid;
+       apriv->proc_entry->uid = proc_kuid;
+       apriv->proc_entry->gid = proc_kgid;
 
        /* Setup the StatsDelta */
        entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_statsdelta_ops, dev);
        if (!entry)
                goto fail_stats_delta;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the Stats */
        entry = proc_create_data("Stats", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_stats_ops, dev);
        if (!entry)
                goto fail_stats;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the Status */
        entry = proc_create_data("Status", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_status_ops, dev);
        if (!entry)
                goto fail_status;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the Config */
        entry = proc_create_data("Config", proc_perm,
                                 apriv->proc_entry, &proc_config_ops, dev);
        if (!entry)
                goto fail_config;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the SSID */
        entry = proc_create_data("SSID", proc_perm,
                                 apriv->proc_entry, &proc_SSID_ops, dev);
        if (!entry)
                goto fail_ssid;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the APList */
        entry = proc_create_data("APList", proc_perm,
                                 apriv->proc_entry, &proc_APList_ops, dev);
        if (!entry)
                goto fail_aplist;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the BSSList */
        entry = proc_create_data("BSSList", proc_perm,
                                 apriv->proc_entry, &proc_BSSList_ops, dev);
        if (!entry)
                goto fail_bsslist;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        /* Setup the WepKey */
        entry = proc_create_data("WepKey", proc_perm,
                                 apriv->proc_entry, &proc_wepkey_ops, dev);
        if (!entry)
                goto fail_wepkey;
-       entry->uid = proc_uid;
-       entry->gid = proc_gid;
+       entry->uid = proc_kuid;
+       entry->gid = proc_kgid;
 
        return 0;
 
@@ -5697,11 +5700,16 @@ static int __init airo_init_module( void )
 {
        int i;
 
+       proc_kuid = make_kuid(&init_user_ns, proc_uid);
+       proc_kgid = make_kgid(&init_user_ns, proc_gid);
+       if (!uid_valid(proc_kuid) || !gid_valid(proc_kgid))
+               return -EINVAL;
+
        airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
 
        if (airo_entry) {
-               airo_entry->uid = proc_uid;
-               airo_entry->gid = proc_gid;
+               airo_entry->uid = proc_kuid;
+               airo_entry->gid = proc_kgid;
        }
 
        for (i = 0; i < 4 && io[i] && irq[i]; i++) {
index 76ffca9729b304c55a8d97afaf0d7a6d5520c6a1..eac23a6fa2369fa5603bc5331f466f25655c89ff 100644 (file)
@@ -1003,8 +1003,6 @@ config UIDGID_CONVERTED
        depends on !UML || HOSTFS = n
 
        # The rare drivers that won't build
-       depends on AIRO = n
-       depends on AIRO_CS = n
        depends on TUN = n
        depends on INFINIBAND_QIB = n
        depends on BLK_DEV_LOOP = n