This is an old revision of the document!


Address Space Layout Randomization (ASLR)

Support for Address Space Layout Randomization was added in FreeBSD HEAD (13-CURRENT) in base r343964. It is enabled by default in 14-CURRENT for 64bit architectures, as of base commit b014e0f15bc7.

ASLR is enabled on a per-ABI basis, and currently only allowed on FreeBSD native i386 and amd64 (including compat 32bit) ABIs. Support for additional architectures will be added after further testing.

Global controls :

  • kern.elf{32,64}.aslr.enable - Enable address map randomization (Default: 1 for 64bit architectures, 0 for 32bit architectures)
  • kern.elf{32,64}.aslr.pie_enable - Enable ASLR for Position-Independent Executables (PIE) binaries (Default: 1 for 64bit architectures, 0 for 32bit architectures)
  • kern.elf{32,64}.aslr.honor_sbrk - Assume sbrk is used (Default: 0)
  • vm.cluster_anon - Cluster anonymous mappings (Default: 1)

Per-process and per-image controls:

  • procctl(2) adds PROC_ASLR_CTL / PROC_ASLR_STATUS
  • NT_FREEBSD_FCTL_ASLR_DISABLE feature control note bit makes it possible to force ASLR off for the given binary. A tool to edit the feature control note is in development.

Application configurations:

  • ntpd will segfault (usually but not always) when stack gap !=0. Either:
    • Set kern.elf64.aslr.stack_gap or kern.elf32.aslr.stack_gap (whichever is applicable to your system) to 0, or
    • Add ntpd_prepend=“/usr/bin/proccontrol -m aslr -s disable” to rc.conf, or
    • If running ntpd by hand or one's own script, proccontrol -m aslr -s disable ntpd $ntpd_args

  • addressspacelayoutrandomization.1642617308.txt.gz
  • Last modified: 2022/01/19 18:35
  • by DanielEbdrup