opnsense-src/sys/vm
Mark Johnston 5fa005e915 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
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1811c1e957)
2022-02-16 11:55:03 -05:00
..
_vm_phys.h vm_phys: Try to clean up NUMA KPIs 2020-11-19 03:59:21 +00:00
_vm_radix.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
default_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-22 12:38:30 +03:00
device_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-22 12:38:30 +03:00
memguard.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
memguard.h LinuxKPI: Implement ksize() function. 2020-08-29 19:26:31 +00:00
phys_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-22 12:38:30 +03:00
pmap.h Add pmap_enter(9) PMAP_ENTER_LARGEPAGE flag and implement it on amd64. 2020-09-09 21:50:24 +00:00
redzone.c redzone: Raise a compile error if KASAN is configured 2021-11-01 10:07:31 -04:00
redzone.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
sg_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-22 12:38:30 +03:00
swap_pager.c swap_pager: uma_zcreate() doesn't fail 2022-01-18 08:36:13 -05:00
swap_pager.h swapoff: add one more variant of the syscall 2021-12-20 02:29:11 +02:00
uma.h uma: Add KASAN state transitions 2021-11-01 10:02:54 -04:00
uma_core.c uma: Avoid polling for an invalid SMR sequence number 2022-01-28 09:13:24 -05:00
uma_dbg.c Fix compilation failures on different arches that have vm_machdep.c not 2019-01-15 19:33:47 +00:00
uma_dbg.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
uma_int.h Improve UMA cache reclamation. 2021-05-15 22:10:48 -04:00
vm.h tmpfs: dynamically register tmpfs pager 2021-05-22 12:38:30 +03:00
vm_domainset.c Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_domainset.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_dumpset.h minidump: Use the provided dump bitset 2021-12-03 10:02:03 -04:00
vm_extern.h vm/vm_extern.h, vm/vm_page.h: use sys/kassert.h 2022-02-08 08:42:07 +02:00
vm_fault.c vm_fault: Fix vm_fault_populate()'s handling of VM_FAULT_WIRE 2021-12-27 19:36:07 -05:00
vm_glue.c Fix a common typo in syctl descriptions 2021-11-06 08:52:57 +01:00
vm_init.c Make MAXPHYS tunable. Bump MAXPHYS to 1M. 2020-11-28 12:12:51 +00:00
vm_kern.c Convert vm_page_alloc() callers to use vm_page_alloc_noobj(). 2021-11-03 13:39:36 -04:00
vm_kern.h Remove the VM map zone. 2020-08-17 13:02:01 +00:00
vm_map.c exec: Reimplement stack address randomization 2022-02-16 11:55:03 -05:00
vm_map.h exec: Reimplement stack address randomization 2022-02-16 11:55:03 -05:00
vm_meter.c vmmeter(): Fix detection of the named swap objects 2022-02-09 02:42:44 +02:00
vm_mmap.c Add OBJT_SWAP_TMPFS pager 2021-05-22 12:38:29 +03:00
vm_object.c vm_object: restore handling of shadow_count for all type of objects 2022-02-09 02:42:44 +02:00
vm_object.h vm_object: Make is_object_active() global 2022-02-09 02:42:44 +02:00
vm_page.c vm_page: Tighten the object lock assertion in vm_page_invalid() 2021-12-13 08:26:34 -05:00
vm_page.h vm/vm_extern.h, vm/vm_page.h: use sys/kassert.h 2022-02-08 08:42:07 +02:00
vm_pageout.c Revert "vm_pageout_scans: correct detection of active object" 2022-02-10 16:56:15 +02:00
vm_pageout.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_pagequeue.h vm_phys: Try to clean up NUMA KPIs 2020-11-19 03:59:21 +00:00
vm_pager.c Use dedicated lock name for pbufs 2022-02-07 11:38:49 +02:00
vm_pager.h vm/vm_pager.h: use sys/systm.h header 2022-02-08 08:42:07 +02:00
vm_param.h (fault 3/9) Move map relookup into a dedicated function. 2020-01-23 05:07:01 +00:00
vm_phys.c minidump: De-duplicate is_dumpable() 2021-10-15 12:20:48 -03:00
vm_phys.h minidump: De-duplicate is_dumpable() 2021-10-15 12:20:48 -03:00
vm_radix.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
vm_radix.h Use SMR to provide a safe unlocked lookup for vm_radix. 2020-02-19 19:58:31 +00:00
vm_reserv.c vm_reserv: fix zero-boundary error 2021-12-29 11:23:48 -06:00
vm_reserv.h Fix locking in vm_reserv_reclaim_contig(). 2019-11-22 16:28:52 +00:00
vm_swapout.c Use a single VM object for kernel stacks. 2020-04-26 20:08:57 +00:00
vm_swapout_dummy.c SPDX: Consider code from Carnegie-Mellon University. 2017-11-30 15:48:35 +00:00
vm_unix.c Prepare to handle non-trivial errors from vm_map_delete(). 2020-09-09 21:34:31 +00:00
vnode_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-22 12:38:30 +03:00
vnode_pager.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00