android_bionic/libc
Evgenii Stepanov d13e9a603f Align-up and randomize shared libraries.
This change implements the following property:
  Any 2**N aligned memory region on size 2**N contains no more than one DSO.

The value N can be configured, with 16 or 18 looking like a good choice.
Additionally, DSOs are loaded at random page-aligned address inside these large
regions.

This change has dual purpose:
1. Larger values of N allow a lot more compact CFI shadow implementation.
   See change I14dfea630de468eb5620e7f55f92b1397ba06217.
   For example, CFI shadow for the system_server process has the following size (RSS, KB):
   152 for N = 12, 32 for N = 16, 16 for N = 18.
2. Extra randomization is good for security.

This change does not result in extra RAM usage, because everything is still page-aligned.
It does result in a bit more VM fragmentation because of the gaps between shared libraries.
As it turns out, this fragmentation is barely noticeable because the kernel creates new mapping
at the highest possible address, and we do enough small mappings to almost completely fill the
gaps (ex. in the Zygote the gaps are filled with .ttf file mappings and thread stacks).

I've measured VM fragmentation as the sum of all VM gaps (unmapped regions) that are larger
than 1MB according to /proc/$PID/maps. On aosp_angler-userdebug, the numbers are (in GB):

                |   N = 12  |  N = 18
system_server   |   521.9   |  521.1
zygote64        |   522.1   |  521.3
zygote32        |   2.55    |  2.55
mediaserver     |   4.00    |  4.00

Change-Id: Ia6df840dd409c82837efd1f263be420d9723c84a
2016-07-19 18:18:22 -07:00
..
arch-arm Support 32-bit ARM vdso. 2016-07-12 13:55:51 -07:00
arch-arm64 Remove deprecated Android.mk files 2016-05-26 16:41:57 -07:00
arch-common/bionic
arch-mips Remove deprecated Android.mk files 2016-05-26 16:41:57 -07:00
arch-mips64 Remove deprecated Android.mk files 2016-05-26 16:41:57 -07:00
arch-x86 Remove deprecated Android.mk files 2016-05-26 16:41:57 -07:00
arch-x86_64 Remove deprecated Android.mk files 2016-05-26 16:41:57 -07:00
bionic Align-up and randomize shared libraries. 2016-07-19 18:18:22 -07:00
dns Remove __LIBC_ABI_PUBLIC__. 2016-07-19 13:56:46 -07:00
include Remove __LIBC_ABI_PUBLIC__. 2016-07-19 13:56:46 -07:00
kernel Update the kernel header documentation. 2016-07-08 15:29:51 -07:00
malloc_debug Convert malloc_debug from Android.mk to Android.bp 2016-07-14 09:07:56 -07:00
private Align-up and randomize shared libraries. 2016-07-19 18:18:22 -07:00
stdio Add ctermid. 2016-06-09 15:16:32 -07:00
stdlib
tools Don't declare SYS_* constants for unavailable __NR_* constants. 2016-07-18 12:48:39 -07:00
tzcode
upstream-freebsd Move <machine/endian.h> somewhere more private. 2016-05-02 15:44:56 -07:00
upstream-netbsd
upstream-openbsd Defer registration of the arc4random fork-detect handler. 2016-06-28 15:52:59 -07:00
zoneinfo Update timezone data to 2016f 2016-07-06 18:41:23 +01:00
Android.bp Remove __LIBC_ABI_PUBLIC__. 2016-07-19 13:56:46 -07:00
Android.mk Rename Android.soong.mk to Android.mk 2016-07-11 16:54:20 -07:00
MODULE_LICENSE_BSD
NOTICE Regenerate NOTICE files. 2016-05-16 17:46:00 -07:00
SYSCALLS.TXT Support 32-bit ARM vdso. 2016-07-12 13:55:51 -07:00
libc.arm.brillo.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.arm.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.arm64.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.map.txt Add ctermid. 2016-06-09 15:16:32 -07:00
libc.mips.brillo.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.mips.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.mips64.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.x86.brillo.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.x86.map Add ctermid. 2016-06-09 15:16:32 -07:00
libc.x86_64.map Add ctermid. 2016-06-09 15:16:32 -07:00
version_script.txt