From: David Carlier <devnexen@gmail.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>
Cc: linux-kernel@vger.kernel.org, David Carlier <devnexen@gmail.com>
Subject: [PATCH 2/2] sched_ext: Fix TOCTOU on p->scx.dsq in scx_dump_task()
Date: Thu, 26 Feb 2026 05:26:40 +0000 [thread overview]
Message-ID: <20260226052640.7191-2-devnexen@gmail.com> (raw)
In-Reply-To: <20260226052640.7191-1-devnexen@gmail.com>
p->scx.dsq is checked for NULL then dereferenced without
synchronization. Another CPU can NULL the pointer between the check
and the use. Use READ_ONCE() to capture the pointer into a local
variable before dereferencing.
Signed-off-by: David Carlier <devnexen@gmail.com>
---
kernel/sched/ext.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index eb539b671c49..444398f3686a 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -4597,9 +4597,11 @@ static void scx_dump_task(struct seq_buf *s, struct scx_dump_ctx *dctx,
unsigned long ops_state = atomic_long_read(&p->scx.ops_state);
unsigned int bt_len = 0;
- if (p->scx.dsq)
+ struct scx_dispatch_q *dsq = READ_ONCE(p->scx.dsq);
+
+ if (dsq)
scnprintf(dsq_id_buf, sizeof(dsq_id_buf), "0x%llx",
- (unsigned long long)p->scx.dsq->id);
+ (unsigned long long)dsq->id);
dump_newline(s);
dump_line(s, " %c%c %s[%d] %+ldms",
--
2.51.0
next prev parent reply other threads:[~2026-02-26 5:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 5:26 [PATCH 1/2] sched_ext: Use rcu_dereference() for scx_root in dump paths David Carlier
2026-02-26 5:26 ` David Carlier [this message]
2026-02-27 18:33 ` [PATCH 2/2] sched_ext: Fix TOCTOU on p->scx.dsq in scx_dump_task() Tejun Heo
2026-02-27 18:41 ` David CARLIER
2026-02-27 18:31 ` [PATCH 1/2] sched_ext: Use rcu_dereference() for scx_root in dump paths Tejun Heo
2026-02-27 19:04 ` David CARLIER
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=20260226052640.7191-2-devnexen@gmail.com \
--to=devnexen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/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.