From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E48AC41C71 for ; Wed, 29 Jul 2026 00:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785283525; cv=none; b=H4e7Qi4dJ15J+GOnlPwrhvW+ptosGPislz0gX/OPrC9ZpHOXbr6vRMbWvX3TUoARtFHdRZTEmkRwea+wS0u0m1MzaoxOObX7GoyrRrFWeqP9JokxT0mD3XvKsb1xh+QgysOVdxfbCC2m3+IzN1gH8pNN/JttmGOe1J436awx+vY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785283525; c=relaxed/simple; bh=ocMEnQNsxbTBxGMRHWysPxrTEJw4AgNz8YckNxxFmII=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=a8ANShyLtiA0V1Y0z+KOeZjyEXm5JvOoseO3jtisx/3ouGwmDD51b+CBdqEUd4cXxxZ30ItfMNgcMuMLzCZUa8NRatB7319uO2+6krsMkdNOtRP2eMdTkaFfZwr2lc79z5Fyn68rrrEUYoMVwJcb5doHASe1fkbyjJy+PoyqsAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iNU8pImz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iNU8pImz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880F41F00A3A; Wed, 29 Jul 2026 00:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785283522; bh=R/Fm4vJ+eQmejH9HhKKsqEyh0Ia6EBL6dZxekAuxzi8=; h=Date:From:To:Cc:Subject:References; b=iNU8pImzS925RY3/khAEOFzgM9LLtHSKHl25JSh4GTlEQu3FTumSq3kQCG2dPFx/w 6dGO/yM86RgUSDZ4hyiuRwvKTeNDO8BkafWEp9LE42WB4Z8lIVieue8t+vN4w3ufig L1ea++qajVFYiq3A7TlCt2UWLEce5bHOLclM97SlixPdqGPb7tkU9HjMR7wir6TuI7 3qSlF9CpkSimyhDNYEKTzaAPvdESjhd+XWjAh+UnzIKMUM8ZX1ayPs34yZ6dEBVE3t viNl49zaleAnIp9qzbUIeyt34fxeZIblCyuiHhkUpuzzsh15qITJu6/M8PsvSnGqQL gSpMQe7rqDLnQ== Received: from rostedt by gandalf with local (Exim 4.99.4) (envelope-from ) id 1woro5-00000006Ufg-0opi; Tue, 28 Jul 2026 20:05:57 -0400 Message-ID: <20260729000557.067013749@kernel.org> User-Agent: quilt/0.69 Date: Tue, 28 Jul 2026 20:05:35 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Samuel Moelius Subject: [for-next][PATCH 12/16] tracing: Reject invalid preemptirq_delay_test CPU affinity References: <20260729000523.093060274@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Samuel Moelius 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 Signed-off-by: Steven Rostedt --- 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 +#include #include #include #include @@ -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