Mandalika's scratchpad | [ Work blog @Oracle | My Music Compositions ] |
Old Posts: 09.04 10.04 11.04 12.04 01.05 02.05 03.05 04.05 05.05 06.05 07.05 08.05 09.05 10.05 11.05 12.05 01.06 02.06 03.06 04.06 05.06 06.06 07.06 08.06 09.06 10.06 11.06 12.06 01.07 02.07 03.07 04.07 05.07 06.07 08.07 09.07 10.07 11.07 12.07 01.08 02.08 03.08 04.08 05.08 06.08 07.08 08.08 09.08 10.08 11.08 12.08 01.09 02.09 03.09 04.09 05.09 06.09 07.09 08.09 09.09 10.09 11.09 12.09 01.10 02.10 03.10 04.10 05.10 06.10 07.10 08.10 09.10 10.10 11.10 12.10 01.11 02.11 03.11 04.11 05.11 07.11 08.11 09.11 10.11 11.11 12.11 01.12 02.12 03.12 04.12 05.12 06.12 07.12 08.12 09.12 10.12 11.12 12.12 01.13 02.13 03.13 04.13 05.13 06.13 07.13 08.13 09.13 10.13 11.13 12.13 01.14 02.14 03.14 04.14 05.14 06.14 07.14 09.14 10.14 11.14 12.14 01.15 02.15 03.15 04.15 06.15 09.15 12.15 01.16 03.16 04.16 05.16 06.16 07.16 08.16 09.16 12.16 01.17 02.17 03.17 04.17 06.17 07.17 08.17 09.17 10.17 12.17 01.18 02.18 03.18 04.18 05.18 06.18 07.18 08.18 09.18 11.18 12.18 01.19 02.19 05.19 06.19 08.19 10.19 11.19 05.20 10.20 11.20 12.20 09.21 11.21 12.22
Address Space Layout Randomization is a security defense mechanism against attacks like buffer overflow or Return Oriented Programming (ROP) attacks that exploit software vulnerabilities. An attacker gaining control of the call stack of a process at runtime to manipulate program control flow to execute instructions of choice is an ROP attack.
All major operating systems including Solaris support Address Space Layout Randomization to minimize the risk of such attacks. In general, user land processes place the starting address of key areas at a known place. ASLR randomizes the starting address of the key areas of the proces address space such as the base of the executable, stack, brk
-based heap, memory mappings including the mapping of libraries.
On Solaris, ASLR is configurable at the system level (global & local zones) and at the binary and process level with the help of sxadm
command line utility. It is possible to enable or disable ASLR for all processes; or selectively enable/disable ASLR for certain applications by tagging related binaries. Tagging is just a special ELF entry inside target binary's dynamic section that explicitly tells whether or not to enable the defense mechanism. Binary tagging has precedence over the system-level configuration. Out of the box, many of userland binaries are tagged on Solaris to enable ASLR; and by default, Solaris boots the global and all non-global zones with ASLR enabled only for those binaries that are explicitly marked (tagged) to support it.
Rest of the post demonstrates ASLR configuration with few examples.
Current ASLR Settings
% sxadm info aslr EXTENSION STATUS CONFIGURATION aslr enabled (tagged-files) default (default)
Above output shows that ASLR is currently enabled for tagged binaries, which is the default behavior on recent Solaris 11 updates.
Tag a Specific Userland Binary to Enable ASLR
Developers can rely on link-editor's "-z aslr=..
" option to selectively tag certain dynamic executables and position-independent executables to enable or disable ASLR for those binaries.
% elfdump -d <somebin> | grep -i aslr % ^^^^ binary not tagged for ASLR .. tag to enable ASLR .. % cc -z aslr <obj-files> -o <somebin> % elfdump -d <somebin> | grep -i aslr [34] SUNW_ASLR 0x2 ENABLE ^^^^^^ binary tagged to enable ASLR .. tag to disable ASLR .. % cc -z aslr=disable <obj-files> -o <somebin> % elfdump -d <somebin> | grep -i aslr [34] SUNW_ASLR 0x1 DISABLE ^^^^^^ binary tagged to disable ASLR
System-wide ASLR Configuration
ASLR is managed as a security extension by the sxadm
command line utility. sxadm
command configures and controls Solaris security extensions both at the system level (global zone, non-global zone) and at the process level.
The enable
and disable
subcommands enable and disable ASLR system-wide, and the delcust
subcommand resets custom ASLR configuration to the out-of-the-box default configuration.
Please check the man page of sxadm(1M)
for detailed information about all supported options.
% sxadm info aslr EXTENSION STATUS CONFIGURATION aslr enabled (tagged-files) default (default) .. enable ASLR system-wide .. # sxadm enable -c model=all aslr # sxadm info aslr EXTENSION STATUS CONFIGURATION aslr enabled (all) enabled (all) .. enable ASLR system-wide only for the tagged binaries .. # sxadm enable -c model=tagged-files aslr # sxadm info aslr EXTENSION STATUS CONFIGURATION aslr enabled (tagged-files) enabled (tagged-files) .. disable ASLR system-wide .. # sxadm disable aslr # sxadm info aslr EXTENSION STATUS CONFIGURATION aslr disabled disabled .. reset custom/current config to default .. # sxadm delcust aslr # sxadm info aslr EXTENSION STATUS CONFIGURATION aslr enabled (tagged-files) default (default)
Runtime Process Level ASLR Configuration
sxadm
command supports runtime process configuration through "sxadm exec
" interface. Child processes of the command executed via "sxadm exec
" inherit the same security extension configuration unless the child process is executing a setuid binary or is more privileged.
# sxadm disable aslr .. enable ASLR during runtime forpmap
process .. # sxadm exec -s aslr=enable /usr/bin/pmap self | grep heap 00000039452A8000 32K rw----- [ heap ] 00000039452B0000 64K rw----- [ heap ] # sxadm exec -s aslr=enable /usr/bin/pmap self | grep heap 00000039B567E000 8K rw----- [ heap ] 00000039B5680000 64K rw----- [ heap ] .. disable ASLR during runtime forpmap
process .. # sxadm exec -s aslr=disable /usr/bin/pmap self | grep heap 000000010010A000 24K rwx---- [ heap ] 0000000100110000 64K rw----- [ heap ] # sxadm exec -s aslr=disable /usr/bin/pmap self | grep heap 000000010010A000 24K rwx---- [ heap ] 0000000100110000 64K rw----- [ heap ]
Binary tagging takes precedence over runtime process conconfiguration if the binary was tagged to disable ASLR.
Note:
ASLR might give a hard time especially during debugging that require consistent and repeatable conditions including address space offsets. In such situations, disable ASLR tentatively for the target binary (best case) or for the entire system (worst case) until the debugging exercise completes.
2004-2019 |