]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
apparmor: fix overlapping attachment computation
authorJohn Johansen <john.johansen@canonical.com>
Sat, 26 Mar 2022 08:58:15 +0000 (01:58 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:57:15 +0000 (11:57 +0200)
BugLink: https://bugs.launchpad.net/bugs/1990564
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: 21f606610502 ("apparmor: improve overlapping domain attachment resolution")
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
security/apparmor/domain.c
security/apparmor/include/policy.h

index 583680f6cd8110a354b7ddfde6e8d4b26b59087e..a7b3d8e58ed83e160a1838191f9c4adc5323d666 100644 (file)
@@ -467,7 +467,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 f1c9cdc49a0dc0bfb167cc6d80133faa807d0496..1ab36c7478f1fb8202dfd5b28da6d52714792ecc 100644 (file)
@@ -136,7 +136,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;