[lkml]   [2019]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[PATCH v2 0/2] x86/mm/KASLR: Change the granularity of randomization to PUD size in 5-level
This is v2 post. v1 can be found here:

Earlier, during a series of KASLR patch reviewing, Ingo got the current
memory region KASLR only has granularity of randomization in PUD size in
4-level paging mode, and P4D size in 5-level paging mode, He suggested
me to try to change both of them to be PMD size at granularity:

Later, I changed code to support PMD level of randomization for both
4-level and 5-level.

The test passed on my KVM guest with 1 GB RAM, but failed when I
increased the RAM to 4 GB, and failed either on larger RAM.

After analyzing, it's because that 1 GB page mapping need be mapped at 1
GB aligned physical address for intel CPU. The 2 MB level of randomization
will break it and cause error. Please check below table in intel IA32 manual.

Table 4-15. Format of an IA-32e Page-Directory-Pointer-Table Entry (PDPTE) that Maps a 1-GByte Page

So PMD level of randomization for mm KASLR is not doable.

However, during investigation and testing above code, it turns out that the
current code is misleading to build identity mapping for the real mode
trampoline in case KASLR enabled. From code, only a small area (which is
smaller than 1 MB) need be identity mapped. Please check below patch which
is from above mm-kaslr-2m-aligned patch series. it only builds up 2 MB
identity maping for real mode trampoline, and test passed on machines
with 32 GB RAM of 4-level and on KVM guest of 5-level.

Make a patchset to:
1)change code to only build 1 GB of area for real mode trampoline,
namely only copy one PUD entry where physical address 0 resides;

2)improve the randomization granularity of 5-level from P4D size to PUD size.

Improve patch according to Kirill's suggestions:
*)Add more information to code comment for better understanding;
*)Improve code to save one low memory page in 4-level;

Baoquan He (2):
x86/mm/KASLR: Only build one PUD entry of area for real mode
x86/mm/KASLR: Change the granularity of randomization to PUD size in

arch/x86/mm/kaslr.c | 92 ++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 52 deletions(-)


 \ /
  Last update: 2019-02-28 01:36    [W:0.097 / U:1.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site