Split early startup code out of locore.S into locore0.S. Adjust link
authorpatrick <patrick@openbsd.org>
Sun, 4 Jun 2017 14:10:42 +0000 (14:10 +0000)
committerpatrick <patrick@openbsd.org>
Sun, 4 Jun 2017 14:10:42 +0000 (14:10 +0000)
commit1cb0e64d9680dc619beeba0dac5a951abf346eae
tree9ffc56314580e1178fe27370a82f12b953c71be5
parentbeea9bb1be8262c40e0433fbe4451d2581e1bab3
Split early startup code out of locore.S into locore0.S.  Adjust link
run so that this locore0.o is always at the start of the executable.
But randomize the link order of all other .o files in the kernel, so
that their exec/rodata/data/bss segments land all over the place.
Late during kernel boot, unmap the early startup code.

As a result, the internal layout of every newly build bsd kernel is
different from past kernels.  Internal relative offsets are not known
to an outside attacker.  The only known offsets are in the startup code,
which has been unmapped.

Ramdisk kernels cannot be compiled like this, because they are gzip'd.
When the internal pointer references change, the compression dictionary
bloats and results in poorer compression.

With guidance and ok deraadt@
sys/arch/arm64/arm64/autoconf.c
sys/arch/arm64/arm64/locore.S
sys/arch/arm64/arm64/locore0.S [new file with mode: 0644]
sys/arch/arm64/conf/Makefile.arm64
sys/arch/arm64/conf/files.arm64