diff options
| author | maxv <maxv@NetBSD.org> | 2017-10-29 11:28:30 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2017-10-29 11:28:30 +0000 |
| commit | f140e8b5282141006a0962c885aaea04d7c7a969 (patch) | |
| tree | f0e83d66ee1164a0375fc393f7c994cc2e72bb2b /sys/dev/microcode/rum/microcode.h | |
| parent | 39791836b222683918ddc2ec428cc83ea2ca29c2 (diff) | |
Randomize the kernel segments independently. That is to say, put text,
rodata and data at different addresses (and in a random order).
To achieve that, the mapping order in the prekern is changed. Until now,
we were creating the kernel map the following way:
-> choose a random VA
-> map [kernpa_start; kernpa_end[ at this VA
-> parse the ELF structures from there
-> determine where exactly the kernel segments are located
-> relocate etc
Now, we are doing:
-> create a read-only view of [kernpa_start; kernpa_end[
-> from this view, compute the size of the "head" region
-> choose a random VA in the HEAD window, and map the head there
-> for each region in (text, rodata, data, boot)
-> compute the size of the region from the RO view
-> choose a random VA in the KASLR window
-> map the region there
-> relocate etc
Each time we map a region, we initialize its bootspace fields right away.
The "head" region must be put before the other regions in memory, because
the kernel uses (headva + sh_offset) to get the addresses of the symbols,
and the offset is unsigned.
Given that the head does not have an mcmodel constraint, its location is
randomized in a window located below the KASLR window.
The rest of the regions being in the same window, we need to detect
collisions.
Note that the module map is embedded in the "boot" region, and that
therefore its location is randomized too.
Diffstat (limited to 'sys/dev/microcode/rum/microcode.h')
0 files changed, 0 insertions, 0 deletions
