Page MenuHomeFreeBSD

Tighten the default permissions on preloaded files.
ClosedPublic

Authored by markj on Oct 1 2019, 7:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 15 2024, 2:08 PM
Unknown Object (File)
Feb 11 2024, 10:22 AM
Unknown Object (File)
Dec 20 2023, 12:55 AM
Unknown Object (File)
Oct 27 2023, 6:54 AM
Unknown Object (File)
Sep 16 2023, 6:06 PM
Unknown Object (File)
Sep 16 2023, 6:04 PM
Unknown Object (File)
Sep 16 2023, 6:03 PM
Unknown Object (File)
Sep 16 2023, 4:34 PM
Subscribers

Details

Summary
  • We load the kernel at 0x200000. Memory below that address need not be executable.
  • Remove references to the .ldata section and related sections. They were just copied from the default GNU ld linker script, but we now use lld (which doesn't embed a default linker script(!)) and we are not going to use ldata anytime soon anyway.
  • Pad the .bss to a 2MB boundary, like we do between .text and .data. This forces the loader to load additional files starting at a different 2MB page. Doing so allows us to keep using superpage mappings for data.
  • Map memory above the kernel with NX. The kernel linker will be modified to use pmap_change_prot() to request execute access. Other preloaded data (/boot/entropy, CPU microcode, etc.) need not be mapped with execute permissions.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added reviewers: alc, kib.
sys/conf/ldscript.amd64
178 ↗(On Diff #62801)

I disgree with this. .bss is the natural part of .data, I do not see why should they be teared apart. Esp. because we do not mmap the .data part for kernel.

sys/conf/ldscript.amd64
178 ↗(On Diff #62801)

I am not tearing them apart - the padding is inserted after .bss, which follows .data.

kib added inline comments.
sys/conf/ldscript.amd64
178 ↗(On Diff #62801)

Yes, I misread the patch. Sorry.

This revision is now accepted and ready to land.Oct 2 2019, 7:33 PM