lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 10 Jun 2022 14:42:12 -0400
From:   Waiman Long <longman@...hat.com>
To:     "Paul E. McKenney" <paulmck@...ux.ibm.com>,
        Frederic Weisbecker <frederic@...nel.org>,
        Neeraj Upadhyay <quic_neeraju@...cinc.com>,
        Josh Triplett <josh@...htriplett.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Joel Fernandes <joel@...lfernandes.org>
Cc:     rcu@...r.kernel.org, linux-kernel@...r.kernel.org,
        "Uladzislau Rezki (Sony)" <urezki@...il.com>,
        Waiman Long <longman@...hat.com>
Subject: [PATCH] rcu-tasks: Delay rcu_tasks_verify_self_tests() to avoid missed callbacks

Even though rcu_tasks selftest is initiated early in the boot process,
the verification done at late initcall time may not be late enough to
catch all the callbacks especially on systems with just a few cpus and
small memory.

After 12 bootup's On a s390x system, 1 of them had failed rcu_tasks
verification test.

[    8.183013] call_rcu_tasks() has been failed.
[    8.183041] WARNING: CPU: 0 PID: 1 at kernel/rcu/tasks.h:1696 rcu_tasks_verify_self_tests+0x64/0xd0
[    8.203246] Callback from call_rcu_tasks() invoked.

In this particular case, the callback missed the check by about
20ms. Similar rcu_tasks selftest failures are also seen in ppc64le
systems.

[    0.313391] call_rcu_tasks() has been failed.
[    0.313407] WARNING: CPU: 0 PID: 1 at kernel/rcu/tasks.h:1696 rcu_tasks_verify_self_tests+0x5c/0xa0
[    0.335569] Callback from call_rcu_tasks() invoked.

Avoid this missed callback by delaying the verification using
delayed_work. The delay is set to be about 0.1s which hopefully will
be long enough to catch all the callbacks on systems with few cpus and
small memory.

Fixes: bfba7ed084f8 ("rcu-tasks: Add RCU-tasks self tests")
Signed-off-by: Waiman Long <longman@...hat.com>
---
 kernel/rcu/tasks.h | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 3925e32159b5..25f964a671ba 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -1735,7 +1735,7 @@ static void rcu_tasks_initiate_self_tests(void)
 #endif
 }
 
-static int rcu_tasks_verify_self_tests(void)
+static void rcu_tasks_verify_self_tests(struct work_struct *work __maybe_unused)
 {
 	int ret = 0;
 	int i;
@@ -1749,10 +1749,23 @@ static int rcu_tasks_verify_self_tests(void)
 
 	if (ret)
 		WARN_ON(1);
+}
+
+static struct delayed_work rcu_tasks_verify_work;
 
-	return ret;
+/*
+ * The rcu_tasks verification is done indirectly via the work queue to
+ * introduce an additional 0.1s delay to catch all the callbacks before
+ * the verification is done as late_initcall time may not be late enough
+ * to have all the callbacks fired.
+ */
+static int rcu_tasks_verify_schedule_work(void)
+{
+	INIT_DELAYED_WORK(&rcu_tasks_verify_work, rcu_tasks_verify_self_tests);
+	schedule_delayed_work(&rcu_tasks_verify_work, HZ/10);
+	return 0;
 }
-late_initcall(rcu_tasks_verify_self_tests);
+late_initcall(rcu_tasks_verify_schedule_work);
 #else /* #ifdef CONFIG_PROVE_RCU */
 static void rcu_tasks_initiate_self_tests(void) { }
 #endif /* #else #ifdef CONFIG_PROVE_RCU */
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ