diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-02 04:57:30 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:23 -0500 |
commit | 9e469e30d712b54cd3ff4a82d4dd5510522b8f16 (patch) | |
tree | e3bf5401b2489973a0b7f10e1f555f24e07f0341 /net/sunrpc/svcauth_unix.c | |
parent | 683428fae8c73d7d7da0fa2e0b6beb4d8df4e808 (diff) |
sunrpc: Hash uids by first computing their value in the initial userns
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>
Diffstat (limited to 'net/sunrpc/svcauth_unix.c')
-rw-r--r-- | net/sunrpc/svcauth_unix.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 92166b57ec7a..faf17195a9fd 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
@@ -419,6 +419,11 @@ struct unix_gid { | |||
419 | struct group_info *gi; | 419 | struct group_info *gi; |
420 | }; | 420 | }; |
421 | 421 | ||
422 | static int unix_gid_hash(kuid_t uid) | ||
423 | { | ||
424 | return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS); | ||
425 | } | ||
426 | |||
422 | static void unix_gid_put(struct kref *kref) | 427 | static void unix_gid_put(struct kref *kref) |
423 | { | 428 | { |
424 | struct cache_head *item = container_of(kref, struct cache_head, ref); | 429 | struct cache_head *item = container_of(kref, struct cache_head, ref); |
@@ -530,7 +535,7 @@ static int unix_gid_parse(struct cache_detail *cd, | |||
530 | ug.h.expiry_time = expiry; | 535 | ug.h.expiry_time = expiry; |
531 | ch = sunrpc_cache_update(cd, | 536 | ch = sunrpc_cache_update(cd, |
532 | &ug.h, &ugp->h, | 537 | &ug.h, &ugp->h, |
533 | hash_long(uid, GID_HASHBITS)); | 538 | unix_gid_hash(uid)); |
534 | if (!ch) | 539 | if (!ch) |
535 | err = -ENOMEM; | 540 | err = -ENOMEM; |
536 | else { | 541 | else { |
@@ -621,7 +626,7 @@ static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid) | |||
621 | struct cache_head *ch; | 626 | struct cache_head *ch; |
622 | 627 | ||
623 | ug.uid = uid; | 628 | ug.uid = uid; |
624 | ch = sunrpc_cache_lookup(cd, &ug.h, hash_long(uid, GID_HASHBITS)); | 629 | ch = sunrpc_cache_lookup(cd, &ug.h, unix_gid_hash(uid)); |
625 | if (ch) | 630 | if (ch) |
626 | return container_of(ch, struct unix_gid, h); | 631 | return container_of(ch, struct unix_gid, h); |
627 | else | 632 | else |