sunrpc: Hash uids by first computing their value in the initial userns
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 2 Feb 2013 09:57:30 +0000 (01:57 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 13 Feb 2013 14:15:23 +0000 (06:15 -0800)
In svcauth_unix introduce a helper unix_gid_hash as otherwise the
expresion to generate the hash value is just too long.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
net/sunrpc/auth.c
net/sunrpc/svcauth_unix.c

index 4cd0ecfe9837c228acff5c4a722879eafe2b1405..392adc41e2e58c09fd34e7872bd39b091cbda096 100644 (file)
@@ -412,7 +412,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
                        *entry, *new;
        unsigned int nr;
 
-       nr = hash_long(acred->uid, cache->hashbits);
+       nr = hash_long(from_kuid(&init_user_ns, acred->uid), cache->hashbits);
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) {
index 92166b57ec7a7cb160e36a7ebaf2f5a94544ad38..faf17195a9fd3482401ce3759d4abb1931fbb313 100644 (file)
@@ -419,6 +419,11 @@ struct unix_gid {
        struct group_info       *gi;
 };
 
+static int unix_gid_hash(kuid_t uid)
+{
+       return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
+}
+
 static void unix_gid_put(struct kref *kref)
 {
        struct cache_head *item = container_of(kref, struct cache_head, ref);
@@ -530,7 +535,7 @@ static int unix_gid_parse(struct cache_detail *cd,
                ug.h.expiry_time = expiry;
                ch = sunrpc_cache_update(cd,
                                         &ug.h, &ugp->h,
-                                        hash_long(uid, GID_HASHBITS));
+                                        unix_gid_hash(uid));
                if (!ch)
                        err = -ENOMEM;
                else {
@@ -621,7 +626,7 @@ static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid)
        struct cache_head *ch;
 
        ug.uid = uid;
-       ch = sunrpc_cache_lookup(cd, &ug.h, hash_long(uid, GID_HASHBITS));
+       ch = sunrpc_cache_lookup(cd, &ug.h, unix_gid_hash(uid));
        if (ch)
                return container_of(ch, struct unix_gid, h);
        else