Split early startup code out of locore.S into locore0.S. Adjust link
authorvisa <visa@openbsd.org>
Thu, 8 Jun 2017 11:44:00 +0000 (11:44 +0000)
committervisa <visa@openbsd.org>
Thu, 8 Jun 2017 11:44:00 +0000 (11:44 +0000)
commitde70334b5a2c09bbc275011f8925056bb02c52e7
tree4649e0e6ae23303c34949fcbdd66e3ba871a4550
parent57d50a524c379e824182da91ab5d7ba0d1551072
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, smash the startup code with traps so that
it does not point to the other randomly placed code.  It has be smashed,
because loongson runs in the kseg0 space.

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.

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.
sys/arch/loongson/conf/Makefile.loongson
sys/arch/loongson/conf/files.loongson
sys/arch/loongson/loongson/autoconf.c
sys/arch/loongson/loongson/locore.S
sys/arch/loongson/loongson/locore0.S [new file with mode: 0644]