From: Samuel Moelius <sam.moelius@trailofbits.com>
To: Kees Cook <kees@kernel.org>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] scftorture: reject zero worker threads
Date: Fri, 5 Jun 2026 18:30:23 +0000 [thread overview]
Message-ID: <20260605183028.2489493-1-sam.moelius@trailofbits.com> (raw)
scftorture accepts nthreads=0. That value skips worker creation, but
module initialization can still create the stats thread when
stat_interval is positive.
Cleanup then tests "nthreads && scf_stats_p" before stopping the stats
task. With nthreads=0, cleanup jumps to the end and leaves the stats
task running after rmmod has returned.
Reject nthreads=0 before allocating state or creating helper threads.
Negative values still retain the existing default-to-online-CPUs
behavior.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
kernel/scftorture.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 327c315f411c..b190d9ff5157 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -661,6 +661,11 @@ static int __init scf_torture_init(void)
// Worker tasks invoking smp_call_function().
if (nthreads < 0)
nthreads = num_online_cpus();
+ if (nthreads == 0) {
+ SCFTORTOUT_ERRSTRING("nthreads must be positive");
+ firsterr = -EINVAL;
+ goto unwind;
+ }
scf_stats_p = kzalloc_objs(scf_stats_p[0], nthreads);
if (!scf_stats_p) {
SCFTORTOUT_ERRSTRING("out of memory");
--
2.43.0
next reply other threads:[~2026-06-05 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 18:30 Samuel Moelius [this message]
2026-06-10 20:15 ` Kees Cook
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=20260605183028.2489493-1-sam.moelius@trailofbits.com \
--to=sam.moelius@trailofbits.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.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
Powered by JetHome