From: Kees Cook <kees@kernel.org>
To: Samuel Moelius <sam.moelius@trailofbits.com>
Cc: open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scftorture: reject zero worker threads
Date: Wed, 10 Jun 2026 13:15:00 -0700 [thread overview]
Message-ID: <202606101314.263450EC@keescook> (raw)
In-Reply-To: <20260605183028.2489493-1-sam.moelius@trailofbits.com>
On Fri, Jun 05, 2026 at 06:30:23PM +0000, Samuel Moelius wrote:
> 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");
Maybe "cannot be zero"? (Negative is a valid option...)
> + 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
>
--
Kees Cook
prev parent reply other threads:[~2026-06-10 20:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 18:30 [PATCH] scftorture: reject zero worker threads Samuel Moelius
2026-06-10 20:15 ` Kees Cook [this message]
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=202606101314.263450EC@keescook \
--to=kees@kernel.org \
--cc=linux-kernel@vger.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.