diff options
author | James Morris <james.l.morris@oracle.com> | 2013-08-22 12:50:12 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2013-08-22 12:50:12 -0400 |
commit | 73203361468894c3c017bfbdd9ddcbb468039604 (patch) | |
tree | bfda3843b96c0056ef84d0957110833bb21f2b02 /security/smack/smack_access.c | |
parent | f8eb8a1324e81927b2c64823b2fc38386efd3fef (diff) | |
parent | 10289b0f738e8b301969f2288c4942455f1b1e59 (diff) |
Merge branch 'smack-for-3.12' of git://git.gitorious.org/smack-next/kernel into ra-next
Diffstat (limited to 'security/smack/smack_access.c')
-rw-r--r-- | security/smack/smack_access.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c index 6a0377f38620..b3b59b1e93d6 100644 --- a/security/smack/smack_access.c +++ b/security/smack/smack_access.c | |||
@@ -325,6 +325,25 @@ void smack_log(char *subject_label, char *object_label, int request, | |||
325 | 325 | ||
326 | DEFINE_MUTEX(smack_known_lock); | 326 | DEFINE_MUTEX(smack_known_lock); |
327 | 327 | ||
328 | struct hlist_head smack_known_hash[SMACK_HASH_SLOTS]; | ||
329 | |||
330 | /** | ||
331 | * smk_insert_entry - insert a smack label into a hash map, | ||
332 | * | ||
333 | * this function must be called under smack_known_lock | ||
334 | */ | ||
335 | void smk_insert_entry(struct smack_known *skp) | ||
336 | { | ||
337 | unsigned int hash; | ||
338 | struct hlist_head *head; | ||
339 | |||
340 | hash = full_name_hash(skp->smk_known, strlen(skp->smk_known)); | ||
341 | head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; | ||
342 | |||
343 | hlist_add_head_rcu(&skp->smk_hashed, head); | ||
344 | list_add_rcu(&skp->list, &smack_known_list); | ||
345 | } | ||
346 | |||
328 | /** | 347 | /** |
329 | * smk_find_entry - find a label on the list, return the list entry | 348 | * smk_find_entry - find a label on the list, return the list entry |
330 | * @string: a text string that might be a Smack label | 349 | * @string: a text string that might be a Smack label |
@@ -334,12 +353,16 @@ DEFINE_MUTEX(smack_known_lock); | |||
334 | */ | 353 | */ |
335 | struct smack_known *smk_find_entry(const char *string) | 354 | struct smack_known *smk_find_entry(const char *string) |
336 | { | 355 | { |
356 | unsigned int hash; | ||
357 | struct hlist_head *head; | ||
337 | struct smack_known *skp; | 358 | struct smack_known *skp; |
338 | 359 | ||
339 | list_for_each_entry_rcu(skp, &smack_known_list, list) { | 360 | hash = full_name_hash(string, strlen(string)); |
361 | head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; | ||
362 | |||
363 | hlist_for_each_entry_rcu(skp, head, smk_hashed) | ||
340 | if (strcmp(skp->smk_known, string) == 0) | 364 | if (strcmp(skp->smk_known, string) == 0) |
341 | return skp; | 365 | return skp; |
342 | } | ||
343 | 366 | ||
344 | return NULL; | 367 | return NULL; |
345 | } | 368 | } |
@@ -475,7 +498,7 @@ struct smack_known *smk_import_entry(const char *string, int len) | |||
475 | * Make sure that the entry is actually | 498 | * Make sure that the entry is actually |
476 | * filled before putting it on the list. | 499 | * filled before putting it on the list. |
477 | */ | 500 | */ |
478 | list_add_rcu(&skp->list, &smack_known_list); | 501 | smk_insert_entry(skp); |
479 | goto unlockout; | 502 | goto unlockout; |
480 | } | 503 | } |
481 | /* | 504 | /* |