[<prev] [next>] [day] [month] [year] [list]
Message-ID: <160788607257.3364.7154683119357481731.tip-bot2@tip-bot2>
Date: Sun, 13 Dec 2020 19:01:12 -0000
From: "tip-bot2 for Paul E. McKenney" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: kernel test robot <lkp@...el.com>,
"Paul E. McKenney" <paulmck@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: core/rcu] refscale: Bounds-check module parameters
The following commit has been merged into the core/rcu branch of tip:
Commit-ID: 0c6d18d84db11840dd0f3f65750c6ea0bb6b8e0d
Gitweb: https://git.kernel.org/tip/0c6d18d84db11840dd0f3f65750c6ea0bb6b8e0d
Author: Paul E. McKenney <paulmck@...nel.org>
AuthorDate: Thu, 27 Aug 2020 09:58:19 -07:00
Committer: Paul E. McKenney <paulmck@...nel.org>
CommitterDate: Mon, 02 Nov 2020 17:13:29 -08:00
refscale: Bounds-check module parameters
The default value for refscale.nreaders is -1, which results in the code
setting the value to three-quarters of the number of CPUs. On single-CPU
systems, this results in three-quarters of the value one, which the C
language's integer arithmetic rounds to zero. This in turn results in
a divide-by-zero error.
This commit therefore adds bounds checking to the refscale module
parameters, so that if they are less than one, they are set to the
value one.
Reported-by: kernel test robot <lkp@...el.com>
Tested-by "Chen, Rong A" <rong.a.chen@...el.com>
Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
---
kernel/rcu/refscale.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index 952595c..fb5f20d 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -681,6 +681,12 @@ ref_scale_init(void)
// Reader tasks (default to ~75% of online CPUs).
if (nreaders < 0)
nreaders = (num_online_cpus() >> 1) + (num_online_cpus() >> 2);
+ if (WARN_ONCE(loops <= 0, "%s: loops = %ld, adjusted to 1\n", __func__, loops))
+ loops = 1;
+ if (WARN_ONCE(nreaders <= 0, "%s: nreaders = %d, adjusted to 1\n", __func__, nreaders))
+ nreaders = 1;
+ if (WARN_ONCE(nruns <= 0, "%s: nruns = %d, adjusted to 1\n", __func__, nruns))
+ nruns = 1;
reader_tasks = kcalloc(nreaders, sizeof(reader_tasks[0]),
GFP_KERNEL);
if (!reader_tasks) {
Powered by blists - more mailing lists