freebsd-dev/sys/i386
Mark Johnston 1811c1e957 exec: Reimplement stack address randomization
The approach taken by the stack gap implementation was to insert a
random gap between the top of the fixed stack mapping and the true top
of the main process stack.  This approach was chosen so as to avoid
randomizing the previously fixed address of certain process metadata
stored at the top of the stack, but had some shortcomings.  In
particular, mlockall(2) calls would wire the gap, bloating the process'
memory usage, and RLIMIT_STACK included the size of the gap so small
(< several MB) limits could not be used.

There is little value in storing each process' ps_strings at a fixed
location, as only very old programs hard-code this address; consumers
were converted decades ago to use a sysctl-based interface for this
purpose.  Thus, this change re-implements stack address randomization by
simply breaking the convention of storing ps_strings at a fixed
location, and randomizing the location of the entire stack mapping.
This implementation is simpler and avoids the problems mentioned above,
while being unlikely to break compatibility anywhere the default ASLR
settings are used.

The kern.elfN.aslr.stack_gap sysctl is renamed to kern.elfN.aslr.stack,
and is re-enabled by default.

PR:		260303
Reviewed by:	kib
Discussed with:	emaste, mw
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 16:12:36 -05:00
..
acpica x86: duplicate acpi_wakeup.c per i386 and amd64 2021-09-14 00:23:14 +03:00
bios Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
conf Remove references to PCMCIA 2021-12-14 15:27:47 -07:00
i386 exec: Introduce the PROC_PS_STRINGS() macro 2022-01-17 16:11:54 -05:00
include Move struct freebsd4_ucontext to sys/i386/include/ucontext.h. 2022-01-13 17:17:43 -08:00
linux exec: Reimplement stack address randomization 2022-01-17 16:12:36 -05:00
pci i386: clean up empty lines in .c and .h files 2020-09-01 21:19:39 +00:00
Makefile Remove iBCS2, part2: general kernel 2018-12-19 21:57:58 +00:00