x86, kaslr: mix entropy sources together as needed
PATCH v2 1/1 x86, kaslr: mix entropy sources together as needed
Depending on availability, mix the RDRAND and RDTSC entropy together with XOR. Only when neither is available should the i8254 be used. Update the Kconfig documentation to reflect this. Additionally, since bits used for entropy is masked elsewhere, drop the needless masking in the get_random_long().
Finally, to improve the starting entropy, do a simple hashing of a build-time versions string and the boot-time boot_params structure for some additional level of unpredictability.
Signed-off-by Kees Cook <[email protected]>
---
v2:
- added build-time string to add to starting entropy; Ingo Molnar.
--- arch/x86/Kconfig | 14 +++++--- arch/x86/boot/compressed/aslr.c | 73 +++++++++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 20 deletions(-)
arch/x86/Kconfig +9 -5
@@ -1736,13 +1736,17 @@ config RANDOMIZE_BASE deters exploit attempts relying on knowledge of the location of kernel internals. - Entropy is generated using the RDRAND instruction if it - is supported. If not, then RDTSC is used, if supported. If - neither RDRAND nor RDTSC are supported, then no randomness - is introduced. + Entropy is generated using the RDRAND instruction if it is + supported. If RDTSC is supported, it is used as well. If + neither RDRAND nor RDTSC are supported, then randomness is + read from the i8254 timer. The kernel will be offset by up to RANDOMIZE_BASE_MAX_OFFSET, - and aligned according to PHYSICAL_ALIGN. + and aligned according to PHYSICAL_ALIGN. Since the kernel is + built using 2GiB addressing, and PHYSICAL_ALGIN must be at a + minimum of 2MiB, only 10 bits of entropy is theoretically + possible. At best, due to page table layouts, 64-bit can use + 9 bits of entropy and 32-bit uses 8 bits. config RANDOMIZE_BASE_MAX_OFFSET hex "Maximum ASLR offset allowed"
arch/x86/boot/compressed/aslr.c +58 -15
98 lines not on this page · raw message
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security