From: Emanuele Rocca <emanuele.rocca@arm.com>
To: John Johansen <john.johansen@canonical.com>,
Georgia Garcia <georgia.garcia@canonical.com>
Cc: apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
"Maxime Bélair" <maxime.belair@canonical.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
stable@vger.kernel.org
Subject: [PATCH] apparmor: fix race on NULL ctx->peer in update_sk_ctx()
Date: Thu, 29 Oct 2026 14:06:43 +0000 [thread overview]
Message-ID: <20261029140643.4092-1-emanuele.rocca@arm.com> (raw)
The unlocked check in update_sk_ctx() can see peer_lastupdate set before
peer is initialized, passing NULL to aa_label_is_subset().
The earlier NULL checks only cover accesses under the socket lock.
Check for NULL and refresh the cache instead.
Fixes: 88fec3526e84 ("apparmor: make sure unix socket labeling is correctly updated.")
Link: https://lore.kernel.org/all/20260824155822.9214-1-maxime.belair@canonical.com/
Cc: stable@vger.kernel.org
Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
---
security/apparmor/af_unix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/apparmor/af_unix.c b/security/apparmor/af_unix.c
index d04d9cd268aa..b95959806303 100644
--- a/security/apparmor/af_unix.c
+++ b/security/apparmor/af_unix.c
@@ -657,9 +657,10 @@ static void update_sk_ctx(struct sock *sk, struct aa_label *label,
bool update_sk;
rcu_read_lock();
+ old = rcu_dereference(ctx->peer);
update_sk = (plabel &&
(plabel != rcu_access_pointer(ctx->peer_lastupdate) ||
- !aa_label_is_subset(plabel, rcu_dereference(ctx->peer)))) ||
+ !old || !aa_label_is_subset(plabel, old))) ||
!__aa_subj_label_is_cached(label, rcu_dereference(ctx->label));
rcu_read_unlock();
if (!update_sk)
--
2.55.0
next reply other threads:[~2026-10-29 14:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 14:06 Emanuele Rocca [this message]
2026-10-29 14:26 ` [PATCH] apparmor: fix race on NULL ctx->peer in update_sk_ctx() sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029140643.4092-1-emanuele.rocca@arm.com \
--to=emanuele.rocca@arm.com \
--cc=apparmor@lists.ubuntu.com \
--cc=aurelien@aurel32.net \
--cc=georgia.garcia@canonical.com \
--cc=john.johansen@canonical.com \
--cc=linux-security-module@vger.kernel.org \
--cc=maxime.belair@canonical.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox