patch-5.15.79-rt54.patch
[platform/kernel/linux-rpi.git] / arch / x86 / include / asm / stackprotector.h
index 24a8d6c..2fc22c2 100644 (file)
@@ -50,7 +50,7 @@
  */
 static __always_inline void boot_init_stack_canary(void)
 {
-       u64 canary;
+       u64 canary = 0;
        u64 tsc;
 
 #ifdef CONFIG_X86_64
@@ -61,8 +61,14 @@ static __always_inline void boot_init_stack_canary(void)
         * 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
        get_random_bytes(&canary, sizeof(canary));
+#endif
        tsc = rdtsc();
        canary += tsc + (tsc << 32UL);
        canary &= CANARY_MASK;