]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: fix overlapping attachment computation
authorJohn Johansen <john.johansen@canonical.com>
Sat, 26 Mar 2022 08:58:15 +0000 (01:58 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 19 Jul 2022 09:52:36 +0000 (02:52 -0700)
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: 21f606610502 ("apparmor: improve overlapping domain attachment resolution")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/domain.c
security/apparmor/include/policy.h

index d71023f5c9c4adedc739fe0d48a370e00918aea2..91689d34d2811db3fef09381248f1c91ae361439 100644 (file)
@@ -466,7 +466,7 @@ restart:
                                 * xattrs, or a longer match
                                 */
                                candidate = profile;
-                               candidate_len = profile->xmatch_len;
+                               candidate_len = max(count, profile->xmatch_len);
                                candidate_xattrs = ret;
                                conflict = false;
                        }
index cb5ef21991b72cc46b288d7680f77b6c705d3ab5..232d3d9566eb7f798430eb641d08b7135190d228 100644 (file)
@@ -135,7 +135,7 @@ struct aa_profile {
 
        const char *attach;
        struct aa_dfa *xmatch;
-       int xmatch_len;
+       unsigned int xmatch_len;
        enum audit_mode audit;
        long mode;
        u32 path_flags;