This is a note to let you know that I've just added the patch titled apparmor: fix overlapping attachment computation to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: apparmor-fix-overlapping-attachment-computation.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 2504db207146543736e877241f3b3de005cbe056 Mon Sep 17 00:00:00 2001 From: John Johansen <john.johansen@xxxxxxxxxxxxx> Date: Sat, 26 Mar 2022 01:58:15 -0700 Subject: apparmor: fix overlapping attachment computation From: John Johansen <john.johansen@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- security/apparmor/domain.c | 2 +- security/apparmor/include/policy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/security/apparmor/domain.c +++ b/security/apparmor/domain.c @@ -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; } --- a/security/apparmor/include/policy.h +++ b/security/apparmor/include/policy.h @@ -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; Patches currently in stable-queue which might be from john.johansen@xxxxxxxxxxxxx are queue-5.15/apparmor-fix-absroot-causing-audited-secids-to-begin-with.patch queue-5.15/apparmor-fix-memleak-in-aa_simple_write_to_buffer.patch queue-5.15/apparmor-fix-setting-unconfined-mode-on-a-loaded-profile.patch queue-5.15/apparmor-fix-quiet_denied-for-file-rules.patch queue-5.15/apparmor-fix-aa_label_asxprint-return-check.patch queue-5.15/apparmor-fix-overlapping-attachment-computation.patch queue-5.15/apparmor-fix-reference-count-leak-in-aa_pivotroot.patch queue-5.15/apparmor-fix-failed-mount-permission-check-error-message.patch