Several mainstream, general-purpose operating systems implement ASLR.
Android Android 4.0 Ice Cream Sandwich provides address space layout randomization (ASLR) to help protect system and third-party applications from exploits due to memory-management issues. Position-independent executable support was added in Android 4.1. Android 5.0 dropped non-PIE support and requires all dynamically linked binaries to be position independent. Library load ordering randomization was accepted into the Android open-source project on 26 October 2015, It is off by default, and can be enabled by setting the sysctl vm.randomize_mmap to 1.
FreeBSD Support for ASLR appeared in
FreeBSD 13.0. It is enabled by default since 13.2.
iOS (iPhone, iPod touch, iPad) Apple introduced ASLR in
iOS 4.3 (released March 2011). KASLR was introduced in iOS 6. The randomized kernel base is , where is a random byte from SHA1 (random data) generated by iBoot (the 2nd-stage iOS Boot Loader).
Linux The
Linux kernel enabled a weak form of ASLR by default since the kernel version 2.6.12, released in June 2005. The
PaX and
Exec Shield patchsets to the Linux kernel provide more complete implementations. The Exec Shield patch for
Linux supplies 19 bits of stack entropy on a period of 16 bytes, and 8 bits of mmap base randomization on a period of 1 page of 4096 bytes. This places the stack base in an area 8 MB wide containing 524,288 possible positions, and the mmap base in an area 1 MB wide containing 256 possible positions. ASLR can be disabled for a specific process by changing its execution domain, using personality(2). A number of
sysctl options control the behavior of mainline ASLR. For example, controls
what to randomize; the strongest option is 2. controls how many bits to randomize for
mmap.
Position-independent executable (PIE) implements a random
base address for the main executable binary and has been in place since April 18, 2004. It provides the same address randomness to the main executable as being used for the shared libraries. The PIE feature cannot be used together with the
prelink feature for the same executable. The prelink tool implements randomization at prelink time rather than runtime, because by design prelink aims to handle relocating libraries before the
dynamic linker has to, which allows the relocation to occur once for many runs of the program. As a result, real address space randomization would defeat the purpose of prelinking. In 2014, Marco-Gisbert and Ripoll disclosed
offset2lib technique that weakens Linux ASLR for PIE executables. Linux kernels load PIE executables right after their libraries; as a result, there is a fixed offset between the executable and the library functions. If an attacker finds a way to find the address of a function in the executable, the library addresses are also known. They demonstrated an attack that finds the address in fewer than 400 tries. They proposed a new option to randomize the placement of the executable relative to the library, The Linux kernel 5.18 released May 2022 reduced the effectiveness of both 32-bit and 64-bit implementations. Linux filesystems call thp_get_unmapped_area to respond to a file-backed
mmap. With a change in 5.18, files greater than 2 MiB are made to return 2 MiB-aligned addresses, so they can be potentially backed by
huge pages. (Previously, the increased alignment only applied to Direct Access (DAX) mappings.) In the meantime, the C library (libc) has, over time, grown in size to exceed this 2 MiB threshold, so instead of being aligned to a (typically) 4 KiB page boundary as before, these libraries are now 2 MiB-aligned: a loss of 9 bits of entropy. For 32-bit Linux, many distributions show no randomization
at all in the placement of the libc. For 64-bit Linux, the 28 bits of entropy is reduced to 19 bits. In response, Ubuntu has increased its setting. Martin Doucha added a
Linux Test Project testcase to detect this issue.
Kernel address space layout randomization Kernel address space layout randomization (KASLR) enables address space randomization for the Linux kernel image by randomizing where the kernel code is placed at boot time. KASLR was merged into the
Linux kernel mainline in kernel version 3.14, released on 30 March 2014. When compiled in, it can be disabled at boot time by specifying as one of the kernel's boot parameters. There are several
side-channel attacks in
x86 processors that could leak kernel addresses. In late 2017,
kernel page-table isolation (KPTI aka KAISER) was developed to defeat these attacks. However, this method cannot protect against side-channel attacks utilizing collisions in
branch predictor structures. , finer grained kernel address space layout randomization (or function granular KASLR, FGKASLR) is a planned extension of KASLR to randomize down to the function level by placing functions in separate sections and reordering them at boot time.
Microsoft Windows Microsoft's
Windows Vista (
released to manufacturing November 2006, generally available January 2007) and later have ASLR enabled only for executables and
dynamic link libraries that are specifically linked to be ASLR-enabled. For compatibility, it is not enabled by default for other applications. Typically, only older software is incompatible and ASLR can be fully enabled by editing a registry entry , or by installing Microsoft's
Enhanced Mitigation Experience Toolkit. The locations of the
heap,
stack, Process Environment Block, and
Thread Environment Block are also randomized. A security whitepaper from Symantec noted that ASLR in 32-bit Windows Vista may not be as robust as expected, and Microsoft has acknowledged a weakness in its implementation. Host-based
intrusion prevention systems such as
WehnTrust and
Ozone also offer ASLR for
Windows XP and
Windows Server 2003 operating systems. WehnTrust is open-source. Complete details of Ozone's implementation are not available. It was noted in February 2012 that ASLR on 32-bit Windows systems prior to
Windows 8 can have its effectiveness reduced in low memory situations. A similar effect also had been achieved on Linux in the same research. The test code caused the Mac OS X 10.7.3 system to
kernel panic, so it was left unclear about its ASLR behavior in this scenario.
NetBSD Support for ASLR in userland appeared in
NetBSD 5.0 (released April 2009), and was enabled by default in NetBSD-current in April 2016. Kernel ASLR support on amd64 was added in NetBSD-current in October 2017, making NetBSD the first BSD system to support KASLR.
OpenBSD In 2003,
OpenBSD became the first mainstream operating system to support a strong form of ASLR and to activate it by default. OpenBSD completed its ASLR support in 2008 when it added support for
PIE binaries. OpenBSD 4.4's
malloc(3) was designed to improve security by taking advantage of ASLR and gap page features implemented as part of OpenBSD's mmap
system call, and to detect use-after-free bugs. Released in 2013, OpenBSD 5.3 was the first mainstream operating system to enable position-independent executables by default on multiple
hardware platforms, and OpenBSD 5.7 activated position-independent static binaries (Static-PIE) by default. In
Mac OS X Lion 10.7 (released July 2011), Apple expanded their implementation to cover all applications, stating "address space layout randomization (ASLR) has been improved for all applications. It is now available for 32-bit apps (as are heap memory protections), making 64-bit and 32-bit applications more resistant to attack." As of
OS X Mountain Lion 10.8 (released July 2012) and later, the entire system including the kernel as well as
kexts and zones are randomly relocated during system boot.
Solaris ASLR has been introduced in
Solaris beginning with Solaris 11.1 (released October 2012). ASLR in Solaris 11.1 can be set system-wide, per zone, or on a per-binary basis. ==Exploitation==