Skip to content

Commit

Permalink
apparmor: Fix regression in profile conflict logic
Browse files Browse the repository at this point in the history
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: 844b829 ("apparmor: ensure that undecidable profile attachments fail")
Cc: Stable <[email protected]>
Signed-off-by: Matthew Garrett <[email protected]>
Signed-off-by: John Johansen <[email protected]>
  • Loading branch information
mjg59 authored and John Johansen committed Jan 12, 2018
1 parent 0dda0b3 commit 1a3881d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions security/apparmor/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,7 @@ static struct aa_profile *__attach_match(const char *name,
continue;

if (profile->xmatch) {
if (profile->xmatch_len == len) {
conflict = true;
continue;
} else if (profile->xmatch_len > len) {
if (profile->xmatch_len >= len) {
unsigned int state;
u32 perm;

Expand All @@ -342,6 +339,10 @@ static struct aa_profile *__attach_match(const char *name,
perm = dfa_user_allow(profile->xmatch, state);
/* any accepting state means a valid match. */
if (perm & MAY_EXEC) {
if (profile->xmatch_len == len) {
conflict = true;
continue;
}
candidate = profile;
len = profile->xmatch_len;
conflict = false;
Expand Down

0 comments on commit 1a3881d

Please sign in to comment.