hc
2023-12-02 57e32c52610e6a560beda60bf33c48f9f42306d5
kernel/arch/x86/include/asm/stackprotector.h
....@@ -65,7 +65,7 @@
6565 */
6666 static __always_inline void boot_init_stack_canary(void)
6767 {
68
- u64 canary;
68
+ u64 uninitialized_var(canary);
6969 u64 tsc;
7070
7171 #ifdef CONFIG_X86_64
....@@ -76,8 +76,14 @@
7676 * of randomness. The TSC only matters for very early init,
7777 * there it already has some randomness on most systems. Later
7878 * on during the bootup the random pool has true entropy too.
79
+ * For preempt-rt we need to weaken the randomness a bit, as
80
+ * we can't call into the random generator from atomic context
81
+ * due to locking constraints. We just leave canary
82
+ * uninitialized and use the TSC based randomness on top of it.
7983 */
84
+#ifndef CONFIG_PREEMPT_RT_FULL
8085 get_random_bytes(&canary, sizeof(canary));
86
+#endif
8187 tsc = rdtsc();
8288 canary += tsc + (tsc << 32UL);
8389 canary &= CANARY_MASK;