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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  9 Jul 2014 10:09:26 -0700
From:	Havard Skinnemoen <hskinnemoen@...gle.com>
To:	Tony Luck <tony.luck@...el.com>, Borislav Petkov <bp@...en8.de>
Cc:	linux-kernel@...r.kernel.org, Ewout van Bekkum <ewout@...gle.com>,
	Havard Skinnemoen <hskinnemoen@...gle.com>
Subject: [PATCH 6/6] x86-mce: ensure the MCP timer is not already set in the mce_timer_fn.

From: Ewout van Bekkum <ewout@...gle.com>

The machine check poll timer function, mce_timer_fn(), did not check
whether the MCP timer had already been set in case the function was
preempted by an interrupt. A CMCI interrupt could preempt this function
and enable the MCP timer through mce_timer_kick(). The race condition
was resolved by disabling interrupts during the mce_timer_fn() function
and by verifying the timer isn't already set before starting the timer.

Signed-off-by: Ewout van Bekkum <ewout@...gle.com>
Signed-off-by: Havard Skinnemoen <hskinnemoen@...gle.com>
---
 arch/x86/kernel/cpu/mcheck/mce.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 1587b18..c5e40cb 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1310,10 +1310,13 @@ static void mce_timer_fn(unsigned long data)
 {
 	struct timer_list *t = &__get_cpu_var(mce_timer);
 	unsigned long iv;
+	unsigned long flags;
 	int notify;
 
 	WARN_ON(smp_processor_id() != data);
 
+	/* Ensure a CMCI interrupt can't preempt this. */
+	local_irq_save(flags);
 	if (mce_available(__this_cpu_ptr(&cpu_info))) {
 		machine_check_poll(MCP_TIMESTAMP,
 				&__get_cpu_var(mce_poll_banks));
@@ -1334,11 +1337,15 @@ static void mce_timer_fn(unsigned long data)
 		iv = mce_adjust_timer(iv);
 	}
 	__this_cpu_write(mce_next_interval, iv);
-	/* Might have become 0 after CMCI storm subsided */
-	if (iv) {
+
+	/* Ensure the timer isn't already set and the interval has not become
+	 * 0 after a CMCMI storm has subsided.
+	 */
+	if (!timer_pending(t) && iv) {
 		t->expires = jiffies + iv;
 		add_timer_on(t, smp_processor_id());
 	}
+	local_irq_restore(flags);
 }
 
 /*
-- 
2.0.0.526.g5318336

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ