apparmor: Fix regression in stacking due to label flags
[ Upstream commit1f939c6bd1
] The unconfined label flag is not being computed correctly. It should only be set if all the profiles in the vector are set, which is different than what is required for the debug and stale flag that are set if any on the profile flags are set. Fixes:c1ed5da197
("apparmor: allow label to carry debug flags") Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
72a5b5641c
commit
f024bf13d4
|
@ -197,15 +197,18 @@ static bool vec_is_stale(struct aa_profile **vec, int n)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long union_vec_flags(struct aa_profile **vec, int n, long mask)
|
static long accum_vec_flags(struct aa_profile **vec, int n)
|
||||||
{
|
{
|
||||||
long u = 0;
|
long u = FLAG_UNCONFINED;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
AA_BUG(!vec);
|
AA_BUG(!vec);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
u |= vec[i]->label.flags & mask;
|
u |= vec[i]->label.flags & (FLAG_DEBUG1 | FLAG_DEBUG2 |
|
||||||
|
FLAG_STALE);
|
||||||
|
if (!(u & vec[i]->label.flags & FLAG_UNCONFINED))
|
||||||
|
u &= ~FLAG_UNCONFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
|
@ -1097,8 +1100,7 @@ static struct aa_label *label_merge_insert(struct aa_label *new,
|
||||||
else if (k == b->size)
|
else if (k == b->size)
|
||||||
return aa_get_label(b);
|
return aa_get_label(b);
|
||||||
}
|
}
|
||||||
new->flags |= union_vec_flags(new->vec, new->size, FLAG_UNCONFINED |
|
new->flags |= accum_vec_flags(new->vec, new->size);
|
||||||
FLAG_DEBUG1 | FLAG_DEBUG2);
|
|
||||||
ls = labels_set(new);
|
ls = labels_set(new);
|
||||||
write_lock_irqsave(&ls->lock, flags);
|
write_lock_irqsave(&ls->lock, flags);
|
||||||
label = __label_insert(labels_set(new), new, false);
|
label = __label_insert(labels_set(new), new, false);
|
||||||
|
|
Loading…
Reference in New Issue