Commit ebc616b9 authored by John Johansen's avatar John Johansen Committed by Tim Gardner

UBUNTU: SAUCE: apparmor: Fix: insert race between label_update and label_merge

BugLink: http://bugs.launchpad.net/bugs/1448912

it is possible for a label_merge to be racing label_update resulting
in the AA_BUG(__aa_label_remove_and_insert()) to trip. Instead check
if a version of label has already been inserted and gracefully fail
if label_update lost the race.
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent 21d27446
......@@ -1782,15 +1782,22 @@ static struct aa_label *__label_update(struct aa_label *label)
if (invcount) {
l->size -= aa_sort_and_merge_profiles(l->size, &l->ent[0]);
if (labels_set(label) == labels_set(l)) {
AA_BUG(__aa_label_remove_and_insert(labels_set(label), label, l) != l);
goto insert;
} else {
aa_label_remove(labels_set(label), label);
goto other_ls_insert;
}
} else {
AA_BUG(labels_ns(label) != labels_ns(l));
AA_BUG(__aa_label_remove_and_insert(labels_set(label), label, l) != l);
goto insert;
}
insert:
tmp = __aa_label_remove_and_insert(labels_set(label), label, l);
if (tmp != l) {
aa_get_label(tmp);
aa_label_free(l);
}
write_unlock_irqrestore(&ls->lock, flags);
return l;
......
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