Commit 0bf390d5 authored by John Johansen's avatar John Johansen Committed by Tim Gardner

UBUNTU: SAUCE: fix: replacedby forwarding is not being properly update when ns is destroyed

Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent 25aee48b
...@@ -333,13 +333,16 @@ struct aa_label *aa_label_alloc(int size, gfp_t gfp) ...@@ -333,13 +333,16 @@ struct aa_label *aa_label_alloc(int size, gfp_t gfp)
return NULL; return NULL;
} }
static bool __aa_label_remove(struct aa_labelset *ls, struct aa_label *label) static bool __aa_label_remove(struct aa_labelset *ls, struct aa_label *label,
struct aa_label *new)
{ {
AA_BUG(!ls); AA_BUG(!ls);
AA_BUG(!label); AA_BUG(!label);
AA_BUG(!write_is_locked(&ls->lock)); AA_BUG(!write_is_locked(&ls->lock));
AA_BUG(labels_set(label) != ls); AA_BUG(labels_set(label) != ls);
if (new)
__aa_update_replacedby(label, new);
if (label_invalid(label)) if (label_invalid(label))
labelstats_dec(invalid_intree); labelstats_dec(invalid_intree);
else else
...@@ -369,8 +372,7 @@ bool aa_label_remove(struct aa_labelset *ls, struct aa_label *l) ...@@ -369,8 +372,7 @@ bool aa_label_remove(struct aa_labelset *ls, struct aa_label *l)
bool res; bool res;
write_lock_irqsave(&ls->lock, flags); write_lock_irqsave(&ls->lock, flags);
__aa_update_replacedby(l, &labels_ns(l)->unconfined->label); res = __aa_label_remove(ls, l, &labels_ns(l)->unconfined->label);
res = __aa_label_remove(ls, l);
write_unlock_irqrestore(&ls->lock, flags); write_unlock_irqrestore(&ls->lock, flags);
return res; return res;
...@@ -419,7 +421,7 @@ static struct aa_label *__aa_label_remove_and_insert(struct aa_labelset *ls, ...@@ -419,7 +421,7 @@ static struct aa_label *__aa_label_remove_and_insert(struct aa_labelset *ls,
AA_BUG(labels_set(remove) != ls); AA_BUG(labels_set(remove) != ls);
AA_BUG(insert->flags & FLAG_IN_TREE); AA_BUG(insert->flags & FLAG_IN_TREE);
__aa_label_remove(ls, remove); __aa_label_remove(ls, remove, insert);
return __aa_label_insert(ls, insert, replace); return __aa_label_insert(ls, insert, replace);
} }
...@@ -462,8 +464,7 @@ bool aa_label_replace(struct aa_label *old, struct aa_label *new) ...@@ -462,8 +464,7 @@ bool aa_label_replace(struct aa_label *old, struct aa_label *new)
struct aa_label *l; struct aa_label *l;
struct aa_labelset *ls = labels_set(old); struct aa_labelset *ls = labels_set(old);
write_lock_irqsave(&ls->lock, flags); write_lock_irqsave(&ls->lock, flags);
__aa_update_replacedby(old, new); res = __aa_label_remove(ls, old, new);
res = __aa_label_remove(ls, old);
if (labels_ns(old) != labels_ns(new)) { if (labels_ns(old) != labels_ns(new)) {
write_unlock_irqrestore(&ls->lock, flags); write_unlock_irqrestore(&ls->lock, flags);
ls = labels_set(new); ls = labels_set(new);
...@@ -1724,7 +1725,11 @@ void aa_labelset_destroy(struct aa_labelset *ls) ...@@ -1724,7 +1725,11 @@ void aa_labelset_destroy(struct aa_labelset *ls)
write_lock_irqsave(&ls->lock, flags); write_lock_irqsave(&ls->lock, flags);
for (node = rb_first(&ls->root); node; node = rb_first(&ls->root)) { for (node = rb_first(&ls->root); node; node = rb_first(&ls->root)) {
struct aa_label *this = rb_entry(node, struct aa_label, node); struct aa_label *this = rb_entry(node, struct aa_label, node);
__aa_label_remove(ls, this); if (ls != &root_ns->labels)
__aa_label_remove(ls, this,
&labels_ns(this)->parent->unconfined->label);
else
__aa_label_remove(ls, this, NULL);
} }
write_unlock_irqrestore(&ls->lock, flags); write_unlock_irqrestore(&ls->lock, flags);
} }
......
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