FAILED: patch "[PATCH] apparmor: use target task's context in apparmor_getprocattr()" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 4afc61702bdcc3b9b519749ef966cf762a6e7051
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050424-extended-ship-1e65@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4afc61702bdcc3b9b519749ef966cf762a6e7051 Mon Sep 17 00:00:00 2001
From: Cengiz Can <[email protected]>
Date: Tue, 10 Feb 2026 11:17:14 +0300
Subject: [PATCH] apparmor: use target task's context in apparmor_getprocattr()
apparmor_getprocattr() incorrectly calls task_ctx(current) instead of task_ctx(task) when retrieving prev and exec attributes, returning the caller's labels rather than the target's.
Fix by passing task to task_ctx().
The issue can be reproduced when a process with an onexec transition (e.g., configured by a container runtime) is inspected via /proc/<pid>/attr/apparmor/exec. The reader's own value is returned instead of the target's.
security/apparmor/lsm.c +7 -9
@@ -822,25 +822,23 @@ static int apparmor_getprocattr(struct task_struct *task, const char *name, char **value) {int error = -ENOENT ; -/* released below */ -const struct cred *cred =get_task_cred (task); -struct aa_task_ctx *ctx =task_ctx (current);struct aa_label *label =NULL ; +rcu_read_lock ();if (strcmp (name,"current" ) ==0 ) - label =aa_get_newest_label (cred_label (cred)); -else if (strcmp (name,"prev" ) ==0 && ctx->previous) - label =aa_get_newest_label (ctx->previous); -else if (strcmp (name,"exec" ) ==0 && ctx->onexec) - label =aa_get_newest_label (ctx->onexec); + label =aa_get_newest_cred_label (__task_cred (task)); +else if (strcmp (name,"prev" ) ==0 &&task_ctx (task)->previous) + label =aa_get_newest_label (task_ctx (task)->previous); +else if (strcmp (name,"exec" ) ==0 &&task_ctx (task)->onexec) + label =aa_get_newest_label (task_ctx (task)->onexec);else error = -EINVAL ; +rcu_read_unlock ();if (label) error =aa_getprocattr (label, value, true);aa_put_label (label); -put_cred (cred);return error; }
Sasha Levin
maintainerPATCH 1/1 apparmor: use target task's context in apparmor_getprocattr()
From: Cengiz Can <[email protected]>
[ Upstream commit 4afc61702bdcc3b9b519749ef966cf762a6e7051 ]
apparmor_getprocattr() incorrectly calls task_ctx(current) instead of task_ctx(task) when retrieving prev and exec attributes, returning the caller's labels rather than the target's.
Fix by passing task to task_ctx().
The issue can be reproduced when a process with an onexec transition (e.g., configured by a container runtime) is inspected via /proc/<pid>/attr/apparmor/exec. The reader's own value is returned instead of the target's.
--- security/apparmor/lsm.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
security/apparmor/lsm.c +7 -9
@@ -598,25 +598,23 @@ static int apparmor_getprocattr(struct task_struct *task, char *name, char **value) {int error = -ENOENT ; -/* released below */ -const struct cred *cred =get_task_cred (task); -struct aa_task_ctx *ctx =task_ctx (current);struct aa_label *label =NULL ; +rcu_read_lock ();if (strcmp (name,"current" ) ==0 ) - label =aa_get_newest_label (cred_label (cred)); -else if (strcmp (name,"prev" ) ==0 && ctx->previous) - label =aa_get_newest_label (ctx->previous); -else if (strcmp (name,"exec" ) ==0 && ctx->onexec) - label =aa_get_newest_label (ctx->onexec); + label =aa_get_newest_cred_label (__task_cred (task)); +else if (strcmp (name,"prev" ) ==0 &&task_ctx (task)->previous) + label =aa_get_newest_label (task_ctx (task)->previous); +else if (strcmp (name,"exec" ) ==0 &&task_ctx (task)->onexec) + label =aa_get_newest_label (task_ctx (task)->onexec);else error = -EINVAL ; +rcu_read_unlock ();if (label) error =aa_getprocattr (label, value);aa_put_label (label); -put_cred (cred);return error; }
Signature · 1 line
2.53.0