summaryrefslogtreecommitdiff
path: root/include/linux/randomize_kstack.h
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2024-08-01 13:06:09 +0300
committerJani Nikula <jani.nikula@intel.com>2024-08-01 13:06:09 +0300
commit3663e2c4bc45fcdc71931fcbfcbfbf9b71f55c83 (patch)
tree3927fa90c7faa89131fcf2e789ca9de97a65dc5f /include/linux/randomize_kstack.h
parent688c43dd6ca9e0cd0568868aefca5b041695c3f4 (diff)
parent8400291e289ee6b2bf9779ff1c83a291501f017b (diff)
downloadlinux-3663e2c4bc45fcdc71931fcbfcbfbf9b71f55c83.tar.xz
Merge drm/drm-next into drm-intel-next
Sync with v6.11-rc1 in general, and specifically get the new BACKLIGHT_POWER_ constants for power states. Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'include/linux/randomize_kstack.h')
-rw-r--r--include/linux/randomize_kstack.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/include/linux/randomize_kstack.h b/include/linux/randomize_kstack.h
index 6d92b68efbf6..1d982dbdd0d0 100644
--- a/include/linux/randomize_kstack.h
+++ b/include/linux/randomize_kstack.h
@@ -32,13 +32,19 @@ DECLARE_PER_CPU(u32, kstack_offset);
#endif
/*
- * Use, at most, 10 bits of entropy. We explicitly cap this to keep the
- * "VLA" from being unbounded (see above). 10 bits leaves enough room for
- * per-arch offset masks to reduce entropy (by removing higher bits, since
- * high entropy may overly constrain usable stack space), and for
- * compiler/arch-specific stack alignment to remove the lower bits.
+ * Use, at most, 6 bits of entropy (on 64-bit; 8 on 32-bit). This cap is
+ * to keep the "VLA" from being unbounded (see above). Additionally clear
+ * the bottom 4 bits (on 64-bit systems, 2 for 32-bit), since stack
+ * alignment will always be at least word size. This makes the compiler
+ * code gen better when it is applying the actual per-arch alignment to
+ * the final offset. The resulting randomness is reasonable without overly
+ * constraining usable stack space.
*/
-#define KSTACK_OFFSET_MAX(x) ((x) & 0x3FF)
+#ifdef CONFIG_64BIT
+#define KSTACK_OFFSET_MAX(x) ((x) & 0b1111110000)
+#else
+#define KSTACK_OFFSET_MAX(x) ((x) & 0b1111111100)
+#endif
/**
* add_random_kstack_offset - Increase stack utilization by previously