Commit 5df1cd95 authored by Stefan Bader's avatar Stefan Bader

Revert "UBUNTU: SAUCE: apparmor: fix label leak when new label is unused"

This reverts commit 848b65c3.

BugLink: https://bugs.launchpad.net/bugs/1666897Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent c2586d4e
...@@ -308,8 +308,6 @@ int aa_vec_unique(struct aa_profile **vec, int n, int flags) ...@@ -308,8 +308,6 @@ int aa_vec_unique(struct aa_profile **vec, int n, int flags)
static void label_destroy(struct aa_label *label) static void label_destroy(struct aa_label *label)
{ {
struct aa_label *tmp;
AA_BUG(!label); AA_BUG(!label);
if (label_is_stale(label)) if (label_is_stale(label))
...@@ -331,11 +329,6 @@ static void label_destroy(struct aa_label *label) ...@@ -331,11 +329,6 @@ static void label_destroy(struct aa_label *label)
rcu_assign_pointer(label->proxy->label, NULL); rcu_assign_pointer(label->proxy->label, NULL);
aa_free_sid(label->sid); aa_free_sid(label->sid);
tmp = rcu_dereference_protected(label->proxy->label, true);
if (tmp == label)
rcu_assign_pointer(label->proxy->label, NULL);
aa_put_proxy(label->proxy); aa_put_proxy(label->proxy);
label->proxy = (struct aa_proxy *) PROXY_POISON + 1; label->proxy = (struct aa_proxy *) PROXY_POISON + 1;
} }
...@@ -387,15 +380,6 @@ void aa_label_kref(struct kref *kref) ...@@ -387,15 +380,6 @@ void aa_label_kref(struct kref *kref)
call_rcu(&label->rcu, label_free_rcu); call_rcu(&label->rcu, label_free_rcu);
} }
static void label_free_or_put_new(struct aa_label *label, struct aa_label *new)
{
if (label != new)
/* need to free directly to break circular ref with proxy */
aa_label_free(new);
else
aa_put_label(new);
}
bool aa_label_init(struct aa_label *label, int size) bool aa_label_init(struct aa_label *label, int size)
{ {
AA_BUG(!label); AA_BUG(!label);
...@@ -858,7 +842,7 @@ static struct aa_label *vec_create_and_insert_label(struct aa_profile **vec, ...@@ -858,7 +842,7 @@ static struct aa_label *vec_create_and_insert_label(struct aa_profile **vec,
write_lock_irqsave(&ls->lock, flags); write_lock_irqsave(&ls->lock, flags);
label = __label_insert(ls, new, false); label = __label_insert(ls, new, false);
write_unlock_irqrestore(&ls->lock, flags); write_unlock_irqrestore(&ls->lock, flags);
label_free_or_put_new(label, new); aa_put_label(new);
return label; return label;
} }
...@@ -1257,7 +1241,7 @@ struct aa_label *aa_label_merge(struct aa_label *a, struct aa_label *b, ...@@ -1257,7 +1241,7 @@ struct aa_label *aa_label_merge(struct aa_label *a, struct aa_label *b,
goto out; goto out;
label = label_merge_insert(new, a, b); label = label_merge_insert(new, a, b);
label_free_or_put_new(label, new); aa_put_label(new);
out: out:
aa_put_label(a); aa_put_label(a);
aa_put_label(b); aa_put_label(b);
...@@ -2058,7 +2042,8 @@ static struct aa_label *__label_update(struct aa_label *label) ...@@ -2058,7 +2042,8 @@ static struct aa_label *__label_update(struct aa_label *label)
/* ensure label is removed, and redirected correctly */ /* ensure label is removed, and redirected correctly */
__label_remove(label, tmp); __label_remove(label, tmp);
write_unlock_irqrestore(&ls->lock, flags); write_unlock_irqrestore(&ls->lock, flags);
label_free_or_put_new(tmp, new);
aa_put_label(new);
return tmp; return tmp;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment