From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Samuele Mariotti <smariotti@disroot.org>,
Paolo Valente <paolo.valente@unimore.it>,
Andrea Righi <arighi@nvidia.com>, Tejun Heo <tj@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.18.y 1/2] sched_ext: Fix missing warning in scx_set_task_state() default case
Date: Thu, 21 May 2026 09:53:57 -0400 [thread overview]
Message-ID: <20260521135358.1280483-1-sashal@kernel.org> (raw)
In-Reply-To: <2026051526-vastness-flattop-e72e@gregkh>
From: Samuele Mariotti <smariotti@disroot.org>
[ 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.
Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Stable-dep-of: 9a415cc53711 ("sched_ext: Avoid UAF in scx_root_enable_workfn() init failure path")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/ext.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 177bbf31116d0..54621f6226886 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2800,7 +2800,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;
}
--
2.53.0
next prev parent reply other threads:[~2026-05-21 13:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 8:43 FAILED: patch "[PATCH] sched_ext: Avoid UAF in scx_root_enable_workfn() init failure" failed to apply to 6.18-stable tree gregkh
2026-05-21 13:53 ` Sasha Levin [this message]
2026-05-21 13:53 ` [PATCH 6.18.y 2/2] sched_ext: Avoid UAF in scx_root_enable_workfn() init failure path Sasha Levin
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=20260521135358.1280483-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=arighi@nvidia.com \
--cc=paolo.valente@unimore.it \
--cc=smariotti@disroot.org \
--cc=stable@vger.kernel.org \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.