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 1F88D331ECA for ; Wed, 10 Jun 2026 20:15:00 +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=1781122502; cv=none; b=Sy28HP6TCVkrRiPfnan0DEVrDIjItkSrYoEzEA7VouqMbPxIbtNzHzAwuqpn68IQbGNv8awDsPEgK7dYadMlRg/6w6i20ElyUj2udccvj1Fiqqo+N/nXO0L7h5qahVelGEifBezW9Agx8z1ca2P4MaLbdvXw899Phksad2tKy6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781122502; c=relaxed/simple; bh=cHzpDj8z8yfTY/SRhl/XR41xeE9yA/rbihB7AB7hRwo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TNk+x38EKzDLZ4s4Re+QWbjKocvpIOFU/iRc42QRnzbIJqu0kUX1196TnwHnXjw8NAlOfk0QSjgr1SWcJsopEq+bm8vLWetcK6pvLPyK+uXc5NUHPbkIz4A+05M66RE4mswcNBZUucRCnLXssXxuBH0WPrxFVpMd2uXpdOpjP/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oAqeMVPs; 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="oAqeMVPs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B82831F00893; Wed, 10 Jun 2026 20:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781122500; bh=Hn/L0YvVfX4yjbHWq1xQ7VCKABWRxyVcrUTjushrEBk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=oAqeMVPsGUvl8ySgn7IpBUMJAYDQhFEqYRHsvr3yKD6a2SAkY7scjIz3NWcjIsPwQ QG1AzQo5A0l1QesX6/K/I6P1r9e5e04oGk2meFa5RafZgnfcFM3s1943dfpTDOjpH2 HAgv935GZCFfRwgiJsH3fKwdgjWJBChppUYtJrGN/F71bOyS9xYvXAWhKUypPIITBJ U7mcah25ZuEv4PGlk9itTvqcQldIQqmM/Zyg/WVzxYD6JuOiSMykp4QB3l49whLEcV 9eVzJeI6vx1sTC8u2e5AzBa8MX/ETWtKlnFBSNo3+N6UdGL2XgxSDXORVSKRhLZLze WuStSaMiQEQ0Q== Date: Wed, 10 Jun 2026 13:15:00 -0700 From: Kees Cook To: Samuel Moelius Cc: open list Subject: Re: [PATCH] scftorture: reject zero worker threads Message-ID: <202606101314.263450EC@keescook> References: <20260605183028.2489493-1-sam.moelius@trailofbits.com> 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=us-ascii Content-Disposition: inline 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 > --- > 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