summaryrefslogtreecommitdiffstats
path: root/security/smack
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-06-10 10:51:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-06-10 23:21:46 -0400
commit8387ff2577eb9ed245df9a39947f66976c6bcd02 (patch)
tree79fafcb5777f16e520d1c39e9389039f866b4c6d /security/smack
parent147d9e7bcad3b8d5465f6eea6292731e7f35dee8 (diff)
vfs: make the string hashes salt the hash
We always mixed in the parent pointer into the dentry name hash, but we did it late at lookup time. It turns out that we can simplify that lookup-time action by salting the hash with the parent pointer early instead of late. A few other users of our string hashes also wanted to mix in their own pointers into the hash, and those are updated to use the same mechanism. Hash users that don't have any particular initial salt can just use the NULL pointer as a no-salt. Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: George Spelvin <linux@sciencehorizons.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/smack')
-rw-r--r--security/smack/smack_access.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index a283f9e796c1..23e5808a0970 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -413,7 +413,7 @@ void smk_insert_entry(struct smack_known *skp)
413 unsigned int hash; 413 unsigned int hash;
414 struct hlist_head *head; 414 struct hlist_head *head;
415 415
416 hash = full_name_hash(skp->smk_known, strlen(skp->smk_known)); 416 hash = full_name_hash(NULL, skp->smk_known, strlen(skp->smk_known));
417 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; 417 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)];
418 418
419 hlist_add_head_rcu(&skp->smk_hashed, head); 419 hlist_add_head_rcu(&skp->smk_hashed, head);
@@ -433,7 +433,7 @@ struct smack_known *smk_find_entry(const char *string)
433 struct hlist_head *head; 433 struct hlist_head *head;
434 struct smack_known *skp; 434 struct smack_known *skp;
435 435
436 hash = full_name_hash(string, strlen(string)); 436 hash = full_name_hash(NULL, string, strlen(string));
437 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; 437 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)];
438 438
439 hlist_for_each_entry_rcu(skp, head, smk_hashed) 439 hlist_for_each_entry_rcu(skp, head, smk_hashed)