From: "tip-bot2 for Aaron Tomlin" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "sashiko-bot" <sashiko-bot@kernel.org>,
Aaron Tomlin <atomlin@atomlin.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/debug: Protect p->mm access in sched_show_numa()
Date: Mon, 09 Nov 2026 09:28:42 -0000 [thread overview]
Message-ID: <179421652257.2093942.16454292958547793774.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261030151307.768523-5-atomlin@atomlin.com>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 5bb5768ef4680edf119dc7ced1d1faf7fbd0bcc6
Gitweb: https://git.kernel.org/tip/5bb5768ef4680edf119dc7ced1d1faf7fbd0bcc6
Author: Aaron Tomlin <atomlin@atomlin.com>
AuthorDate: Fri, 30 Oct 2026 11:13:05 -04:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 09 Nov 2026 10:23:57 +01:00
sched/debug: Protect p->mm access in sched_show_numa()
In sched_show_numa(), p->mm is checked locklessly and then passed to the
P(mm->numa_scan_seq) macro. This presents both a time-of-change to
time-of-use race and a potential use-after-free vulnerability.
If a task exits concurrently via exit_mm(p), another CPU can set p->mm
to NULL and call mmput(mm) to free the struct mm_struct. Dereferencing
mm->numa_scan_seq without holding task_lock(p) can access freed memory if
mmput() runs immediately after the check.
Fix this by wrapping the p->mm check and macro dereference in
task_lock(p) and task_unlock(p). In exit_mm(), current->mm is set to
NULL under task_lock(p) before mmput() is called, guaranteeing that
p->mm cannot be set to NULL or freed while task_lock(p) is held.
Fixes: b32e86b4301e ("sched/numa: Add debugging")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/20261030151307.768523-5-atomlin@atomlin.com
---
kernel/sched/debug.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index be886ed..a22d646 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -1389,8 +1389,10 @@ void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
static void sched_show_numa(struct task_struct *p, struct seq_file *m)
{
#ifdef CONFIG_NUMA_BALANCING
+ task_lock(p);
if (p->mm)
P(mm->numa_scan_seq);
+ task_unlock(p);
P(numa_pages_migrated);
P(numa_preferred_nid);
next prev parent reply other threads:[~2026-11-09 9:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 15:13 [PATCH v11 tip/sched/core 0/6] Introduce per-CPU debugfs files Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 1/6] sched: Annotate rq->rd with __rcu and update lockless readers Aaron Tomlin
2026-11-09 8:44 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` [tip: sched/core] sched/core: " tip-bot2 for Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 2/6] sched/debug: Protect lockless rq->rd access in print_dl_rq() Aaron Tomlin
2026-11-09 8:44 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` tip-bot2 for Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 3/6] sched/debug: Protect lockless rq->curr access in print_cpu() Aaron Tomlin
2026-11-09 8:43 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` tip-bot2 for Aaron Tomlin
2026-11-09 10:02 ` tip-bot2 for Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 4/6] sched/debug: Protect p->mm access in sched_show_numa() Aaron Tomlin
2026-11-09 8:43 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` tip-bot2 for Aaron Tomlin [this message]
2026-11-09 10:02 ` tip-bot2 for Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 5/6] sched/fair: Use list_for_each_entry_rcu() in print_cfs_stats() Aaron Tomlin
2026-11-09 8:43 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` tip-bot2 for Aaron Tomlin
2026-11-09 10:02 ` tip-bot2 for Aaron Tomlin
2026-10-30 15:13 ` [PATCH v11 tip/sched/core 6/6] sched/debug: Introduce per-CPU debugfs files Aaron Tomlin
2026-11-09 8:43 ` [tip: sched/core] " tip-bot2 for Aaron Tomlin
2026-11-09 9:28 ` tip-bot2 for Aaron Tomlin
2026-11-09 10:02 ` tip-bot2 for Aaron Tomlin
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=179421652257.2093942.16454292958547793774.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=atomlin@atomlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sashiko-bot@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®