diff options
| author | Tejun Heo <tj@kernel.org> | 2024-07-30 09:30:11 -1000 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2024-07-30 09:30:11 -1000 |
| commit | c8faf11cd192214e231626c3ee973a35d8fc33f2 (patch) | |
| tree | 4c3fcfddf4c7c311e1856dbf4dac1240564731f1 /include/linux/randomize_kstack.h | |
| parent | 8bb30798fd6ee79e4041a32ca85b9f70345d8671 (diff) | |
| parent | 8400291e289ee6b2bf9779ff1c83a291501f017b (diff) | |
Merge tag 'v6.11-rc1' into for-6.12
Linux 6.11-rc1
Diffstat (limited to 'include/linux/randomize_kstack.h')
| -rw-r--r-- | include/linux/randomize_kstack.h | 18 |
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 |
