Commit 1a3881d3 authored by Matthew Garrett's avatar Matthew Garrett Committed by John Johansen

apparmor: Fix regression in profile conflict logic

The intended behaviour in apparmor profile matching is to flag a
conflict if two profiles match equally well. However, right now a
conflict is generated if another profile has the same match length even
if that profile doesn't actually match. Fix the logic so we only
generate a conflict if the profiles match.

Fixes: 844b8292 ("apparmor: ensure that undecidable profile attachments fail")
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: default avatarMatthew Garrett <mjg59@google.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 0dda0b3f
...@@ -330,10 +330,7 @@ static struct aa_profile *__attach_match(const char *name, ...@@ -330,10 +330,7 @@ static struct aa_profile *__attach_match(const char *name,
continue; continue;
if (profile->xmatch) { if (profile->xmatch) {
if (profile->xmatch_len == len) { if (profile->xmatch_len >= len) {
conflict = true;
continue;
} else if (profile->xmatch_len > len) {
unsigned int state; unsigned int state;
u32 perm; u32 perm;
...@@ -342,6 +339,10 @@ static struct aa_profile *__attach_match(const char *name, ...@@ -342,6 +339,10 @@ static struct aa_profile *__attach_match(const char *name,
perm = dfa_user_allow(profile->xmatch, state); perm = dfa_user_allow(profile->xmatch, state);
/* any accepting state means a valid match. */ /* any accepting state means a valid match. */
if (perm & MAY_EXEC) { if (perm & MAY_EXEC) {
if (profile->xmatch_len == len) {
conflict = true;
continue;
}
candidate = profile; candidate = profile;
len = profile->xmatch_len; len = profile->xmatch_len;
conflict = false; conflict = false;
......
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