Skip to content

Commit 53b626f

Browse files
petkomanolovMimi Zohar
authored andcommitted
IMA: use list_splice_tail_init_rcu() instead of its open coded variant
Use list_splice_tail_init_rcu() to extend the existing custom IMA policy with additional IMA policy rules. Signed-off-by: Petko Manolov <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent b4df860 commit 53b626f

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

security/integrity/ima/ima_policy.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -527,22 +527,9 @@ int ima_check_policy(void)
527527
*/
528528
void ima_update_policy(void)
529529
{
530-
struct list_head *first, *last, *policy;
530+
struct list_head *policy = &ima_policy_rules;
531531

532-
/* append current policy with the new rules */
533-
first = (&ima_temp_rules)->next;
534-
last = (&ima_temp_rules)->prev;
535-
policy = &ima_policy_rules;
536-
537-
synchronize_rcu();
538-
539-
last->next = policy;
540-
rcu_assign_pointer(list_next_rcu(policy->prev), first);
541-
first->prev = policy->prev;
542-
policy->prev = last;
543-
544-
/* prepare for the next policy rules addition */
545-
INIT_LIST_HEAD(&ima_temp_rules);
532+
list_splice_tail_init_rcu(&ima_temp_rules, policy, synchronize_rcu);
546533

547534
if (ima_rules != policy) {
548535
ima_policy_flag = 0;

0 commit comments

Comments
 (0)