FAILED: patch "[PATCH] sched_ext: Avoid UAF in scx_root_enable_workfn() init failure" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-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-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 9a415cc53711f2238e0f0ca8a6bcc796c003b127
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051527-snort-dawn-9645@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9a415cc53711f2238e0f0ca8a6bcc796c003b127 Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Mon, 11 May 2026 12:05:48 -1000
Subject: [PATCH] sched_ext: Avoid UAF in scx_root_enable_workfn() init failure
path
In scx_root_enable_workfn(), put_task_struct(p) is called before scx_error() dereferences p->comm and p->pid. If the iterator's reference is the last drop, the task is freed synchronously and the deref becomes a UAF.
Move put_task_struct() past scx_error().
kernel/sched/ext.c +1 -1
@@ -6973,10 +6973,10 @@ static void scx_root_enable_workfn(struct kthread_work *work)if (scx_get_task_state (p) !=SCX_TASK_DEAD )scx_set_task_state (p,SCX_TASK_NONE );task_rq_unlock (rq, p, &rf); -put_task_struct (p);scx_task_iter_stop (&sti);scx_error (sch,"ops.init_task() failed (%d) for %s[%d]" , ret, p->comm, p->pid); +put_task_struct (p); goto err_disable_unlock_all; }
Sasha Levin
maintainerPATCH 1/2 sched_ext: Fix missing warning in scx_set_task_state() default case
From: Samuele Mariotti <[email protected]>
[ Upstream commit b905ee77d5f557a83a485b4146210f54f13365fc ]
In scx_set_task_state(), the default case was setting the warn flag, but then returning immediately. This is problematic because the only purpose of the warn flag is to trigger WARN_ONCE, but the early return prevented it from ever firing, leaving invalid task states undetected and untraced.
To fix this, a WARN_ONCE call is now added directly in the default case.
The fix addresses two aspects:
- Guarantees the invalid task states are properly logged and traced.
- Provides a distinct warning message ("sched_ext: Invalid task state") specifically for states outside the defined scx_task_state enum values, making it easier to distinguish from other transition warnings.
This ensures proper detection and reporting of invalid states.
Stable-dep-of: 9a415cc53711 ("sched_ext: Avoid UAF in scx_root_enable_workfn() init failure path")
--- kernel/sched/ext.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/ext.c +2 -1
@@ -3637,7 +3637,8 @@ static void scx_set_task_state(struct task_struct *p, enum scx_task_state state) warn = prev_state !=SCX_TASK_READY ;break ;default : - warn = true; +WARN_ONCE (1 ,"sched_ext: Invalid task state %d -> %d for %s[%d]" , + prev_state, state, p->comm, p->pid);return ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 sched_ext: Avoid UAF in scx_root_enable_workfn() init failure path
From: Tejun Heo <[email protected]>
[ Upstream commit 9a415cc53711f2238e0f0ca8a6bcc796c003b127 ]
In scx_root_enable_workfn(), put_task_struct(p) is called before scx_error() dereferences p->comm and p->pid. If the iterator's reference is the last drop, the task is freed synchronously and the deref becomes a UAF.
Move put_task_struct() past scx_error().
--- kernel/sched/ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext.c +1 -1
@@ -5406,11 +5406,11 @@ static void scx_ops_enable_workfn(struct kthread_work *work) ret =scx_ops_init_task (p,task_group (p), false);if (ret) { -put_task_struct (p);scx_task_iter_relock (&sti);scx_task_iter_stop (&sti);scx_ops_error ("ops.init_task() failed (%d) for %s[%d]" , ret, p->comm, p->pid); +put_task_struct (p); goto err_disable_unlock_all; }
Signature · 1 line
2.53.0