apparmor: fix overlapping attachment computation
authorJohn Johansen <john.johansen@canonical.com>
Sat, 26 Mar 2022 08:58:15 +0000 (01:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:00 +0000 (11:40 +0200)
commitc62f2f56e086526e24075cc21fece53c602aa116
treec57a1c90586315296b4f9313bce8fd59d4f7bbe2
parente89b95f91e632c662a3374abd8cb49f542d12ebf
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: 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>
security/apparmor/domain.c
security/apparmor/include/policy.h