2020-03-06 11:44:27 +00:00
|
|
|
From fdddc5f9de75c797965fbb4c41826941313f97e3 Mon Sep 17 00:00:00 2001
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
Date: Thu, 16 Dec 2010 14:25:18 +0100
|
2020-04-09 19:44:24 +00:00
|
|
|
Subject: [PATCH 227/328] x86: stackprotector: Avoid random pool on rt
|
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.106-rt46.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
CPU bringup calls into the random pool to initialize the stack
|
|
|
|
canary. During boot that works nicely even on RT as the might sleep
|
|
|
|
checks are disabled. During CPU hotplug the might sleep checks
|
|
|
|
trigger. Making the locks in random raw is a major PITA, so avoid the
|
|
|
|
call on RT is the only sensible solution. This is basically the same
|
|
|
|
randomness which we get during boot where the random pool has no
|
|
|
|
entropy and we rely on the TSC randomnness.
|
|
|
|
|
|
|
|
Reported-by: Carsten Emde <carsten.emde@osadl.org>
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
arch/x86/include/asm/stackprotector.h | 8 +++++++-
|
2018-08-27 14:32:32 +00:00
|
|
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
|
|
|
|
index 8ec97a62c245..7bc85841fc56 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/arch/x86/include/asm/stackprotector.h
|
|
|
|
+++ b/arch/x86/include/asm/stackprotector.h
|
|
|
|
@@ -60,7 +60,7 @@
|
|
|
|
*/
|
|
|
|
static __always_inline void boot_init_stack_canary(void)
|
|
|
|
{
|
|
|
|
- u64 canary;
|
|
|
|
+ u64 uninitialized_var(canary);
|
|
|
|
u64 tsc;
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -71,8 +71,14 @@ static __always_inline void boot_init_stack_canary(void)
|
2018-08-27 14:32:32 +00:00
|
|
|
* of randomness. The TSC only matters for very early init,
|
|
|
|
* there it already has some randomness on most systems. Later
|
|
|
|
* on during the bootup the random pool has true entropy too.
|
|
|
|
+ * For preempt-rt we need to weaken the randomness a bit, as
|
|
|
|
+ * we can't call into the random generator from atomic context
|
|
|
|
+ * due to locking constraints. We just leave canary
|
|
|
|
+ * uninitialized and use the TSC based randomness on top of it.
|
|
|
|
*/
|
|
|
|
+#ifndef CONFIG_PREEMPT_RT_FULL
|
|
|
|
get_random_bytes(&canary, sizeof(canary));
|
|
|
|
+#endif
|
|
|
|
tsc = rdtsc();
|
|
|
|
canary += tsc + (tsc << 32UL);
|
|
|
|
canary &= CANARY_MASK;
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-04-09 19:44:24 +00:00
|
|
|
2.25.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|