From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C21C63ACEF0 for ; Sun, 28 Jun 2026 15:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782662327; cv=none; b=KMckOrxzH56dhvAcsmS8A5RVBfolaDalmOx8eaHS5DmVG8ru6uXYUN7tVM9oIocY4c5Uogm9XJPG8RewtyvELjXH3CpzZ4o/TLIk1TUTMJPWJV1BkeHDsZ8PAfVgedTQPRj57JgpHNQA7aa2km91GVDEH9Z21+6ji9S3uIvP1Kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782662327; c=relaxed/simple; bh=o5vMTyCkOIu2LmLBdE3v7rq9Aa9meM0HbdE6FBCYeVg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pr2WGHTRxRtsXohO0B/NpN7wrOxpURbILwWggUCKNnGpPNOYEMJt5cViscTaoc4Aq5aT/FdUY3jmJNztSHRVz0HQQ92fsYt9vPhKf1XBwARvKjRcpnZEGp8DgiqUYhxeUnqZm1Nz1EwBw18lOQ3Ucguy4aTCae3Z7+CI9VMMnPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b=U1ymZQGn; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b="U1ymZQGn" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-51bfad59921so1339751cf.0 for ; Sun, 28 Jun 2026 08:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1782662325; x=1783267125; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nRr7ggqg/BOsptB4FuZ5lejePz1nhDGQe+3qxHA1BRg=; b=U1ymZQGn3lSAtk+PokMUTg9sB6ijfU/AV7La19evzCs/v8QwBL2DyXFAR+5qXSdwux 6ksWKcPTyq315wyk4XfdGW1lfMCtUteGTtTmxraxs3PxR6Kk3vwqetUz0FX2Da3WrNSd P0I1is2NnVywDRq9qEAiLF1Lv5piovp1/7OzUE5dDNYRjegR+ueF4LhnbCgSZZBJT3ae fJWmgc4P6IZVxTlfOPej8LMA8cY/S8QDymYJ4TSNurwEqcj47lkHhK4zh7NEqzJzoJb+ itQ/df93ma+rI0d0qQyCE54McOYRDeB+Gj1ySoSlkyFgV3VAfqThygyIAvqYejWzo8rE 6kuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782662325; x=1783267125; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nRr7ggqg/BOsptB4FuZ5lejePz1nhDGQe+3qxHA1BRg=; b=Hj1YcZCeSbtoLqLZ3TtQ3yTf2/Ay41PXU9TqZH/x+q5h0FGHr1lzJOl75ufiBd3hsq E1FpjEGCPlw5JWaWlFVxrdvvkSqrTRcXRIIGsfxhybFKwYUH9jonJKDDsWvBbILbeuIh Osb6P4wxAIBZqaxgLePN71pAUpDLy6h/22OML6fmLRU8nht/J5Dq9tvBRwrmt1Xsdbtj YJASeCtItrNjs1Ks6zjUUaEMevsq2UrDQBqZi0Fzh6KUZucLj5PsSjZ0TmRRx41W5Bi+ bjytxyIXZPL9hEcKROy10p9zhrWItvD2j9Ds1xXIqTMiHf0xJ/f1oUFOGUZdPhK+6V9B kjWg== X-Forwarded-Encrypted: i=1; AFNElJ8z89bnPfqiDU5EXmm7RQTiWucCwMPfwCPhlN9srdqV7P7eVWhuIlbTO9PHNis76phBcdHRkd8Ppkdk/eY=@vger.kernel.org X-Gm-Message-State: AOJu0YwM0DWZ/hLKl9xmGSze5m44dMNWilZV19LbT83y8a0wMZdP2GYQ FTnGj2ONgshJBNwd6PiSVXgpMqIDC/M2qBvh0HOlVpzGY7zTfuLbQm95lANhDembxCygTRS8Skr t+GRl5RM= X-Gm-Gg: AfdE7clvZdvFvVB0pRs6//zRYJIA2wsXSriZb45nvMIuLD1eRXeunX++IXF38F+PH0L 0Mb1PfK2HkyNvGaBLpK1GVRdQlzZNa10y4KKkxwnAulndvKo+ZxiSdDFq4VNV0A7kqjksAiWWN9 j/v0/YKJ/06ZjtE/zlKoeuxhaB9kFsPJGDDI7AjdcPBeUuTfNvkS9CGTW4Ob5cLOX1bgc7wS7wp 1sH6+yE+Bs3CHrhgsGA5sY404FNFCtezcdSwV2CtOGVrHAYjvp0WhiZMIPjo4cuU+LEGMjxfWWr F33xa+18yb8T5+2jx94llmnQgj/qZb2UisNVzDpIk3aKApbuOHqOwMCkxtnCK5DvChs/6aM28Lm aT3W3SSjTZFeIdtRLyfJha6INFxcgRDnyCYFeYHWKo/qauzEG6dSjU6iw0F1apt9iS+YiiM11L1 ckLGV9Yl01t9fNL/jtKLAwgcSKVzU= X-Received: by 2002:a05:622a:105:b0:51a:8c9c:7f36 with SMTP id d75a77b69052e-51a8c9c83d6mr96479061cf.57.1782662324759; Sun, 28 Jun 2026 08:58:44 -0700 (PDT) Received: from localhost ([161.35.96.86]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-51be972190asm32937511cf.22.2026.06.28.08.58.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jun 2026 08:58:43 -0700 (PDT) From: Samuel Moelius To: Samuel Moelius Cc: Kees Cook , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] scftorture: reject zero worker threads Date: Sun, 28 Jun 2026 15:57:55 +0000 Message-ID: <20260628155750.84186.102c06f26d8a.scftorture-zero-nthreads-stats-thread@trailofbits.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- Changes in v2: - Adjust error message kernel/scftorture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/scftorture.c b/kernel/scftorture.c index 327c315f411c..eca6e13fa06f 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 cannot be zero"); + 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