From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
Samuel Moelius <sam.moelius@trailofbits.com>
Subject: [for-next][PATCH 12/16] tracing: Reject invalid preemptirq_delay_test CPU affinity
Date: Tue, 28 Jul 2026 20:05:35 -0400 [thread overview]
Message-ID: <20260729000557.067013749@kernel.org> (raw)
In-Reply-To: 20260729000523.093060274@kernel.org
From: Samuel Moelius <sam.moelius@trailofbits.com>
preemptirq_delay_test accepts cpu_affinity as a module parameter and,
when it is non-negative, writes that CPU directly into a temporary
cpumask from the worker thread. Values outside nr_cpu_ids can set a bit
outside the allocated cpumask before the test reports a normal affinity
error.
Validate the requested CPU in preemptirq_delay_run() before setting it
in the temporary cpumask. Invalid affinity requests are reported by
the test thread and skipped before cpumask_set_cpu() can touch an
out-of-range bit.
Link: https://patch.msgid.link/20260628131021.2208632.6a5c6c959813.preemptirq-delay-test-invalid-cpu-affinity@trailofbits.com
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/preemptirq_delay_test.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
index acb0c971a408..69e5238737ed 100644
--- a/kernel/trace/preemptirq_delay_test.c
+++ b/kernel/trace/preemptirq_delay_test.c
@@ -6,6 +6,7 @@
*/
#include <linux/trace_clock.h>
+#include <linux/cpumask.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
@@ -123,6 +124,13 @@ static int preemptirq_delay_run(void *data)
return -ENOMEM;
if (cpu_affinity > -1) {
+ unsigned int cpu = cpu_affinity;
+
+ if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) {
+ pr_err("cpu_affinity:%d, invalid CPU\n", cpu_affinity);
+ goto out;
+ }
+
cpumask_clear(cpu_mask);
cpumask_set_cpu(cpu_affinity, cpu_mask);
if (set_cpus_allowed_ptr(current, cpu_mask))
@@ -132,6 +140,7 @@ static int preemptirq_delay_run(void *data)
for (i = 0; i < s; i++)
(testfuncs[i])(i);
+out:
complete(&done);
set_current_state(TASK_INTERRUPTIBLE);
--
2.53.0
next prev parent reply other threads:[~2026-07-29 0:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 0:05 [for-next][PATCH 00/16] tracing: Updates for v7.3 Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 01/16] bpf: Make btf_get_module_btf() and btf_relocate_id() non-static Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 02/16] tracing: Expose tracepoint BTF ids via tracefs Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 03/16] selftests/bpf: Add test for tracepoint btf_ids tracefs file Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 04/16] tracing: Point constant hist field type to string literal Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 05/16] kernel/trace/trace_printk: Use kstrdup() instead of kmalloc() and strcpy() Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 06/16] tracing: Use __free() for expr_str() buffer Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 07/16] tracing: Return ERR_PTR() from expr_str() Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 08/16] tracing: Bound histogram expression strings with seq_buf Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 09/16] tracing/user_events: Use seq_putc() in two functions Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 10/16] tracing/user_events: Replace a seq_printf() call by seq_puts() in user_seq_show() Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 11/16] fgraph: Use trace_seq_putc() in print_graph_return() Steven Rostedt
2026-07-29 0:05 ` Steven Rostedt [this message]
2026-07-29 0:05 ` [for-next][PATCH 13/16] samples/ftrace: Prevent division by zero when nr_function_calls is zero Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 14/16] tracing: Warn when an event dereferences a pointer in TP_printk() Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 15/16] tracing: Use strscpy() instead of strcpy() in trace_sched_switch Steven Rostedt
2026-07-29 0:05 ` [for-next][PATCH 16/16] tracing: Use seq_buf for string concatenation Steven Rostedt
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=20260729000557.067013749@kernel.org \
--to=rostedt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=sam.moelius@trailofbits.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.