Skip to content

x86/boot/KASLR: enhance randomness of kernel load addr when using GiB hugepage

Pingfan Liu lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3x86/boot/KASLR: change the prototypes of process_efi_entries/process_e820_entriesarch/x86/boot/compressed/kaslr.c+13 -70 replies
2/3x86/boot/KASLR: change the prototype of process_mem_region() to meet the align requirementarch/x86/boot/compressed/kaslr.c+24 -120 replies
3/3x86/boot/KASLR: enhance randomness when using GiB hugepagearch/x86/boot/compressed/kaslr.c+116 -580 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] x86/boot/KASLR: enhance randomness of kernel load addr when using GiB hugepage

commit 747ff6265db4 ("x86/boot/KASLR: Skip specified number of 1GB huge pages when doing physical randomization (KASLR)") and commit 9b912485e0e7 ("x86/boot/KASLR: Add two new functions for 1GB huge pages handling") prevent the physical load addr of kernel from spoiling a good candidate of GiB page. But the algorithm deterministicly chooses the most front GiB page for hugetlb, and sacrifices the randomness, which is the heart of the KASLR. This patch tries to enlarge the randomness in the cases where hugepages=X < the num Y of good candidate of GiB page.
To comparison, taking a typical KVM guest for example, the head 3GiB mem can not be used as GiB hugetlb. Denoting the total mem size as Z(GiB), when Z=5, then Y=2, assuming X=1, the randomness range before this patch is 4GiB, after this patch is 5GiB, and get a 25% improvement of randomness. If Z=6, then Y=3, assuming X=2, the improvement equals: 50%( 6/(6-2) - 1); assuming X=1, the improvement will be: 20% (6/(6-1) - 1)

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Baoquan He <[email protected]>
Cc Chao Fan <[email protected]> (authored:1/16=6%)

Pingfan Liu (3):
x86/boot/KASLR: change the prototypes of
process_efi_entries/process_e820_entries
x86/boot/KASLR: change the prototype of process_mem_region() to meet
the align requirement
x86/boot/KASLR: enhance randomness when using GiB hugepage

 arch/x86/boot/compressed/kaslr.c | 228 ++++++++++++++++++++++++++-------------
 1 file changed, 152 insertions(+), 76 deletions(-)
Signature · 1 line
2.7.4