freebsd-dev/sys/i386/linux
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
..
imgact_linux.c exec: Reimplement stack address randomization 2022-01-17 16:12:36 -05:00
linux_copyout.c Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
linux_dummy_machdep.c linux(4): Implement ppoll_time64 system call. 2021-06-10 15:18:46 +03:00
linux_genassym.c
linux_locore.asm linux(4); Almost complete the vDSO. 2021-07-20 10:01:18 +03:00
linux_machdep.c linux: remove the always curthread argument from lconvpath 2021-11-25 22:50:42 +00:00
linux_proto.h Revert "syscallarg_t: Add a type for system call arguments" 2022-01-12 23:29:20 +00:00
linux_ptrace_machdep.c linux: mv sys/i386/linux/linux_ptrace{,_machdep}.c 2021-11-03 08:50:17 +00:00
linux_syscall.h linux(4): Regen for linux_poll system call. 2021-06-22 08:09:55 +03:00
linux_syscalls.c linux(4): Regen for linux_poll system call. 2021-06-22 08:09:55 +03:00
linux_sysent.c Revert "syscallarg_t: Add a type for system call arguments" 2022-01-12 23:29:20 +00:00
linux_systrace_args.c syscalls: regen 2021-11-22 22:36:57 +00:00
linux_sysvec.c exec: Introduce the PROC_PS_STRINGS() macro 2022-01-17 16:11:54 -05:00
linux_vdso_gtod.c linux(4): Fix gcc buld. 2021-07-29 09:52:33 +03:00
linux_vdso.lds.s linux(4); Almost complete the vDSO. 2021-07-20 10:01:18 +03:00
linux.h linux: implement sigaltstack(2) on arm64 2021-07-27 13:34:49 +00:00
Makefile sysent targets: further cleanup and deduplication 2020-01-18 20:37:45 +00:00
syscalls.conf sysent: move away from allowing all compat options for other ABIs 2021-12-16 20:56:28 -06:00
syscalls.master linux(4): Implement clone3 system call. 2021-08-12 11:49:36 +03:00