summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorSamuel Moelius <sam.moelius@trailofbits.com>2026-06-28 13:10:22 +0000
committerSteven Rostedt <rostedt@goodmis.org>2026-07-28 07:18:50 -0400
commit693dc27c5286cb0fd0d8cf18c3ee924b22154e92 (patch)
treea149ea565928de5bf236ce5da557ed6ad3dc7966 /kernel
parent73301fb81a17dbf198a5bf6cdaefa3611232b88e (diff)
tracing: Reject invalid preemptirq_delay_test CPU affinity
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/preemptirq_delay_test.c9
1 files changed, 9 insertions, 0 deletions
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);