android_bionic/libc/private
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
..
ErrnoRestorer.h
KernelArgumentBlock.h Tidy up KernelArgumentBlock::getauxval. 2016-01-05 16:29:33 -08:00
NetdClientDispatch.h
ScopeGuard.h
ScopedPthreadMutexLocker.h Explicitly disallow default c-tor 2015-12-01 16:57:19 -08:00
ScopedReaddir.h Implement scandirat and scandirat64. 2015-10-27 13:47:36 -07:00
ThreadLocalBuffer.h Make ThreadLocalBuffer a class rather than a macro. 2015-03-31 10:56:58 -07:00
UniquePtr.h
WriteProtected.h Move VDSO pointers to a shared globals struct. 2015-10-09 15:59:04 -07:00
__get_tls.h
bionic_asm.h Add a no dwarf version of assembler macros. 2015-09-30 15:32:15 -07:00
bionic_auxv.h
bionic_config.h
bionic_constants.h
bionic_errdefs.h Move <sys/_sigdefs.h> and <sys/_errdefs.h> to private. 2016-04-13 17:45:39 -07:00
bionic_fortify.h Improve FORTIFY failure diagnostics. 2016-02-26 22:06:17 -08:00
bionic_futex.h Use FUTEX_WAIT_BITSET to avoid converting timeouts. 2015-11-19 13:42:03 -08:00
bionic_globals.h libc: implement kernel vdso syscalls for i386 2016-03-25 14:10:05 -07:00
bionic_ieee.h Move the IEEE fp header out of the public headers. 2016-05-02 12:44:41 -07:00
bionic_lock.h Merge "Use FUTEX_WAIT_BITSET to avoid converting timeouts." 2015-11-21 01:50:29 +00:00
bionic_macros.h Align-up and randomize shared libraries. 2016-07-19 18:18:22 -07:00
bionic_malloc_dispatch.h Export malloc_iterate and friends 2016-02-18 15:05:38 -08:00
bionic_mbstate.h
bionic_page.h Move PAGE_MASK into <sys/user.h>. 2015-07-28 14:58:37 -07:00
bionic_prctl.h
bionic_sdk_version.h Revert "Revert "Make sem_wait able to return errno EINTR for sdk > 23."" 2016-01-25 17:39:18 -08:00
bionic_sigdefs.h Move <sys/_sigdefs.h> and <sys/_errdefs.h> to private. 2016-04-13 17:45:39 -07:00
bionic_ssp.h
bionic_string_utils.h
bionic_systrace.h
bionic_time_conversions.h Make it harder to use a broken legacy function by accident. 2016-04-04 16:15:37 -07:00
bionic_tls.h Improve and fix the stack-protector tests. 2016-03-09 14:50:03 -08:00
bionic_vdso.h Support 32-bit ARM vdso. 2016-07-12 13:55:51 -07:00
get_cpu_count_from_string.h Fix the way to count online cpus. 2015-09-29 17:49:37 -07:00
kernel_sigset_t.h Move some pthread functions to signal.h. 2014-11-21 10:26:09 -08:00
libc_logging.h x86-64's va_list is not a pointer type. 2016-06-30 13:47:16 -07:00
thread_private.h Defer registration of the arc4random fork-detect handler. 2016-06-28 15:52:59 -07:00