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]
Message-ID: <20240823080046.61736-1-qiyuzhu2@amd.com>
Date: Fri, 23 Aug 2024 08:00:46 +0000
From: Zhu Qiyu <qiyuzhu2@....com>
To: <paulmck@...nel.org>, <neeraj.upadhyay@...nel.org>
CC: <riel@...riel.com>, <leobras@...hat.com>, <tglx@...utronix.de>,
	<thorsten.blum@...lux.com>, <qiyuzhu2@....com>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH] locking/csd_lock: fix csd_lock_wait_toolong() error warning

From: "Zhu Qiyu" <qiyuzhu2@....com>

In AC cycle stress tests, it was found that the csd_lock_wait_toolong()
did not reach the 5s threshold, but printed the warning message, the
probability of occurrence is about 0.58%-0.87%.

This is due to the out-of-order execution of the CPU, which causes ts2
to be used before it is initialized. The original value of ts2 on the
stack is random, which may cause ts_delta = ts2 - *ts1 to be greater
than 5s, thus triggering the printing.

The solution is to add a memory barrier after reading the ts2, which
can effectively avoid this issue.

Signed-off-by: Zhu Qiyu <qiyuzhu2@....com>
---
 kernel/smp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/smp.c b/kernel/smp.c
index f25e20617b7e..e58678d424a4 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -247,6 +247,8 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in
 	}
 
 	ts2 = sched_clock();
+	/* Avoid ts2 being used before it is initialized */
+	mb();
 	/* How long since we last checked for a stuck CSD lock.*/
 	ts_delta = ts2 - *ts1;
 	if (likely(ts_delta <= csd_lock_timeout_ns * (*nmessages + 1) *
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ