HomeFreeBSD

Tighten mapping protections on preloaded files on amd64.

Description

Tighten mapping protections on preloaded files on amd64.

  • We load the kernel at 0x200000. Memory below that address need not be executable, so do not map it as such.
  • Remove references to .ldata and related sections in the kernel linker script. They come from ld.bfd's default linker script, but are not used, and we now use ld.lld to link the amd64 kernel. lld does not contain a default linker script.
  • Pad the .bss to a 2MB as we do between .text and .data. This forces the loader to load additional files starting in the following 2MB page, preserving the use of superpage mappings for kernel data.
  • Map memory above the kernel image with NX. The kernel linker now upgrades protections as needed, and other preloaded file types (e.g., entropy, microcode) need not be mapped with execute permissions in the first place.

Reviewed by: kib
MFC after: 1 month
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21859

Details

Provenance
markjAuthored on
Reviewer
kib
Differential Revision
D21859: Tighten the default permissions on preloaded files.
Parents
rS353730: Apply mapping protections to preloaded kernel modules on amd64.
Branches
Unknown
Tags
Unknown