Commit 9e469e30d712b54cd3ff4a82d4dd5510522b8f16
1 parent
683428fae8
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 2 changed files with 8 additions and 3 deletions Side-by-side Diff
net/sunrpc/auth.c
... | ... | @@ -412,7 +412,7 @@ |
412 | 412 | *entry, *new; |
413 | 413 | unsigned int nr; |
414 | 414 | |
415 | - nr = hash_long(acred->uid, cache->hashbits); | |
415 | + nr = hash_long(from_kuid(&init_user_ns, acred->uid), cache->hashbits); | |
416 | 416 | |
417 | 417 | rcu_read_lock(); |
418 | 418 | hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { |
net/sunrpc/svcauth_unix.c
... | ... | @@ -419,6 +419,11 @@ |
419 | 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 | 427 | static void unix_gid_put(struct kref *kref) |
423 | 428 | { |
424 | 429 | struct cache_head *item = container_of(kref, struct cache_head, ref); |
... | ... | @@ -530,7 +535,7 @@ |
530 | 535 | ug.h.expiry_time = expiry; |
531 | 536 | ch = sunrpc_cache_update(cd, |
532 | 537 | &ug.h, &ugp->h, |
533 | - hash_long(uid, GID_HASHBITS)); | |
538 | + unix_gid_hash(uid)); | |
534 | 539 | if (!ch) |
535 | 540 | err = -ENOMEM; |
536 | 541 | else { |
... | ... | @@ -621,7 +626,7 @@ |
621 | 626 | struct cache_head *ch; |
622 | 627 | |
623 | 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 | 630 | if (ch) |
626 | 631 | return container_of(ch, struct unix_gid, h); |
627 | 632 | else |