apparmor: fix overlapping attachment computation

commit 2504db207146543736e877241f3b3de005cbe056 upstream.

When finding the profile via patterned attachments, the longest left
match is being set to the static compile time value and not using the
runtime computed value.

Fix this by setting the candidate value to the greater of the
precomputed value or runtime computed value.

Fixes: 21f6066105 ("apparmor: improve overlapping domain attachment resolution")
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
John Johansen 2022-03-26 01:58:15 -07:00 committed by Greg Kroah-Hartman
parent 98ab8dfa04
commit 7f6092dc8f
2 changed files with 2 additions and 2 deletions

View File

@ -460,7 +460,7 @@ restart:
* xattrs, or a longer match * xattrs, or a longer match
*/ */
candidate = profile; candidate = profile;
candidate_len = profile->xmatch_len; candidate_len = max(count, profile->xmatch_len);
candidate_xattrs = ret; candidate_xattrs = ret;
conflict = false; conflict = false;
} }

View File

@ -135,7 +135,7 @@ struct aa_profile {
const char *attach; const char *attach;
struct aa_dfa *xmatch; struct aa_dfa *xmatch;
int xmatch_len; unsigned int xmatch_len;
enum audit_mode audit; enum audit_mode audit;
long mode; long mode;
u32 path_flags; u32 path_flags;