OSDN Git Service
Elliott Hughes [Mon, 25 Jun 2012 21:09:42 +0000 (14:09 -0700)]
am
5af97ca8: am
c7bab8cb: Merge "Enable sqrtf() x86 assembly code"
* commit '
5af97ca8514d9fb4175bff3a79abf26889b94530':
Enable sqrtf() x86 assembly code
Elliott Hughes [Mon, 25 Jun 2012 21:06:06 +0000 (14:06 -0700)]
am
c7bab8cb: Merge "Enable sqrtf() x86 assembly code"
* commit '
c7bab8cb8483e7869eabdbd4add7c9e5beeecc80':
Enable sqrtf() x86 assembly code
Elliott Hughes [Mon, 25 Jun 2012 17:46:41 +0000 (10:46 -0700)]
Merge "Enable sqrtf() x86 assembly code"
xqian6 [Mon, 25 Jun 2012 08:12:06 +0000 (16:12 +0800)]
Enable sqrtf() x86 assembly code
This patch can improve the sqrtf() performance.
Change-Id: Ic9d11d6a9ecd9b263f54d4878e13595e136b95ce
Evgeniy Stepanov [Fri, 22 Jun 2012 10:52:52 +0000 (14:52 +0400)]
Add module base to main executable's ARM_exidx.
BUG:
6697872
Change-Id: I448f4b86397307086231776da38a7af334a75fe5
Andrew Hsieh [Thu, 21 Jun 2012 02:00:55 +0000 (19:00 -0700)]
am
fa136e8c: am
a5948157: Merge "Define __stack_chk_fail_local.S"
* commit '
fa136e8ca71cb20956cd1792251869cac8bed257':
Define __stack_chk_fail_local.S
Andrew Hsieh [Thu, 21 Jun 2012 01:58:18 +0000 (18:58 -0700)]
am
a5948157: Merge "Define __stack_chk_fail_local.S"
* commit '
a5948157fd34acb2b1d1bfaf129901af865ab5fc':
Define __stack_chk_fail_local.S
Andrew Hsieh [Thu, 21 Jun 2012 01:37:47 +0000 (18:37 -0700)]
Merge "Define __stack_chk_fail_local.S"
Andrew Hsieh [Wed, 20 Jun 2012 06:35:51 +0000 (14:35 +0800)]
Define __stack_chk_fail_local.S
With -fstack-protector, x86 -m32 needs __stack_chk_fail_local
defined in crtbegin_*.o.
Include __stack_chk_fail_local.S in begin.S otherwise linker
(which is built w/o crt*) may not link.
Change-Id: Id242fcf3eff157264afe3b04f27288ab7991220a
The Android Open Source Project [Wed, 20 Jun 2012 15:28:23 +0000 (08:28 -0700)]
The Android Open Source Project [Wed, 20 Jun 2012 15:25:32 +0000 (08:25 -0700)]
Reconcile with jb-release
Change-Id: Ia5de9692e507a605d3b6937ec65da26169a3ea8e
The Android Automerger [Wed, 20 Jun 2012 13:59:21 +0000 (06:59 -0700)]
merge in jb-release history after reset to jb-dev
David 'Digit' Turner [Tue, 19 Jun 2012 21:51:28 +0000 (14:51 -0700)]
Merge "linker: reduce size by nearly 20KB"
Andy McFadden [Tue, 19 Jun 2012 18:33:19 +0000 (11:33 -0700)]
am
63c4179f: am
4d0128f1: Merge "Minor tweak to get memory around corrupted heap chunks dumped." into jb-dev
* commit '
63c4179f5951edc2d68700fe75659fbd34febe63':
Minor tweak to get memory around corrupted heap chunks dumped.
Andy McFadden [Tue, 19 Jun 2012 18:31:14 +0000 (11:31 -0700)]
am
4d0128f1: Merge "Minor tweak to get memory around corrupted heap chunks dumped." into jb-dev
* commit '
4d0128f13a3ca9f7a0c81b6e69f7e20d28e9e6e3':
Minor tweak to get memory around corrupted heap chunks dumped.
Andy McFadden [Tue, 19 Jun 2012 18:28:15 +0000 (11:28 -0700)]
Merge "Minor tweak to get memory around corrupted heap chunks dumped." into jb-dev
Ben Cheng [Tue, 19 Jun 2012 14:11:38 +0000 (07:11 -0700)]
Minor tweak to get memory around corrupted heap chunks dumped.
Change-Id: I8f72c5c7e23960b13fc53e2354cd74aca8aac3c0
David 'Digit' Turner [Tue, 19 Jun 2012 00:02:32 +0000 (02:02 +0200)]
linker: reduce size by nearly 20KB
This patch adds a trivial implementation of snprintf() that calls
our internal vsnprintf().
Inspection of the generated machine code showed that the linker
contained a full implementation of stdio's vfprintf. It was pulled
in because the pthread implementation uses snprintf() somewhere.
ProTip: It's possible to see why specific objects files are included
in a final binary by adding the following to your Android.mk, then
looking at the content of /tmp/MAP.TXT:
LOCAL_LDFLAGS += -Wl,-Map=/tmp/MAP.TXT
Change-Id: I325e71b0cad1d01116a2e00c09e30a80cb716aa3
Arve Hjønnevåg [Thu, 14 Jun 2012 23:13:16 +0000 (16:13 -0700)]
Merge "Add watchdog.h"
Nick Kralevich [Thu, 14 Jun 2012 20:48:18 +0000 (13:48 -0700)]
libc: make atoi, atol, and atoll pure functions
Change-Id: Ib831c079c865929b6c91d42f35e117f2e974808f
Nick Kralevich [Wed, 13 Jun 2012 23:57:27 +0000 (16:57 -0700)]
FORTIFY_SOURCE: add strlcpy / strlcat support
Add strlcpy / strlcat support to FORTIFY_SOURCE. This allows
us to do consistency checks on to ensure we don't overflow buffers
when the compiler is able to tell us the size of the buffer we're
dealing with.
Unlike previous changes, this change DOES NOT use the compiler's
builtin support. Instead, we do everything the compiler would
normally do.
Change-Id: I47c099a911382452eafd711f8e9bfe7c2d0a0d22
Arve Hjønnevåg [Thu, 14 Jun 2012 02:22:18 +0000 (19:22 -0700)]
Add watchdog.h
Change-Id: Ib12d437151ccfbd634e9f01acd8556c79977ca04
David 'Digit' Turner [Thu, 14 Jun 2012 04:45:52 +0000 (21:45 -0700)]
Merge "linker: small code-cleanup"
Nick Kralevich [Wed, 13 Jun 2012 23:13:32 +0000 (16:13 -0700)]
Merge "Don't mark realloc with __attribute__((malloc))"
Nick Kralevich [Wed, 13 Jun 2012 22:43:14 +0000 (15:43 -0700)]
Don't mark realloc with __attribute__((malloc))
According to
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
realloc should NOT be marked with __attribute__((malloc)). Quoting:
realloc-like functions do not have this property as the memory
pointed to does not have undefined content.
For reference, __mallocfunc is defined in sys/cdefs.h as:
#define __mallocfunc __attribute__((malloc))
Change-Id: I56083542ba92e4608dd7c55fb5596a138eb50cc9
David 'Digit' Turner [Tue, 12 Jun 2012 14:25:37 +0000 (16:25 +0200)]
linker: small code-cleanup
This patch adds to make the linker a little bit easier to understand
by making all functions that acts on a sofino object with a soinfo_
prefix.
This is to more easily distinguish functions that operate on global
state, and those that operate on individual libraries.
This should be purely stylistic, i.e. no feature/behaviour change.
Change-Id: Ie510d13d743aa4317644caefa9910b8af7e84f44
Nick Kralevich [Wed, 13 Jun 2012 18:03:42 +0000 (11:03 -0700)]
Merge "FORTIFY_SOURCE: add sprintf / vsprintf support"
Nick Kralevich [Tue, 12 Jun 2012 22:59:04 +0000 (15:59 -0700)]
FORTIFY_SOURCE: add sprintf / vsprintf support
sprintf FORTIFY_SOURCE protections are not available
on clang.
Also add various __attribute__s to stdio functions.
Change-Id: I936d1f9e55fe53a68885c4524b7b59e68fed218d
Nick Kralevich [Tue, 12 Jun 2012 23:34:46 +0000 (16:34 -0700)]
Merge "update filter.h / prctl.h / seccomp.h"
Robert Greenwalt [Tue, 12 Jun 2012 22:56:29 +0000 (15:56 -0700)]
am
c5cab345: am
028ccf5d: Merge "Avoid multiple dns lookups for the same query"
* commit '
c5cab3452d5ced55474e56497594579108670b51':
Avoid multiple dns lookups for the same query
Robert Greenwalt [Tue, 12 Jun 2012 22:52:56 +0000 (15:52 -0700)]
am
028ccf5d: Merge "Avoid multiple dns lookups for the same query"
* commit '
028ccf5d40dd9a945ea92aa79822c08c6f6aa1d2':
Avoid multiple dns lookups for the same query
Nick Kralevich [Tue, 12 Jun 2012 22:42:39 +0000 (15:42 -0700)]
update filter.h / prctl.h / seccomp.h
Pull in an updated version of filter.h / prctl.h / seccomp.h
from the linux kernel. Pulled from upstream kernel at
94fa83c424321189ca24fb6cb4c0d224cdedc72d
This file was generated using the following command:
cd bionic/libc/kernel/
./tools/clean_header.py -u ../../../external/kernel-headers/original/linux/seccomp.h
./tools/clean_header.py -u ../../../external/kernel-headers/original/linux/filter.h
./tools/clean_header.py -u ../../../external/kernel-headers/original/linux/prctl.h
Change-Id: I1ca996541d05b0d5927ab828a6ce49c09877ea01
Robert Greenwalt [Tue, 12 Jun 2012 22:06:23 +0000 (15:06 -0700)]
Merge "Avoid multiple dns lookups for the same query"
Nick Kralevich [Tue, 12 Jun 2012 15:50:57 +0000 (08:50 -0700)]
Merge "FORTIFY_SOURCE: add snprintf, vsnprintf"
Elliott Hughes [Tue, 12 Jun 2012 00:42:44 +0000 (17:42 -0700)]
am
20afd4e7: am
e0961445: Merge "Remove the meaningless on Linux if_dl.h header."
* commit '
20afd4e70c2f346d7cd03a7a3049f8de2d176d5c':
Remove the meaningless on Linux if_dl.h header.
Elliott Hughes [Tue, 12 Jun 2012 00:42:43 +0000 (17:42 -0700)]
am
571da80c: am
c75491e2: Merge "Remove an obsolete jamfile."
* commit '
571da80c58e13eac4d4fb29d38342879e5dede13':
Remove an obsolete jamfile.
Elliott Hughes [Tue, 12 Jun 2012 00:41:10 +0000 (17:41 -0700)]
am
e0961445: Merge "Remove the meaningless on Linux if_dl.h header."
* commit '
e0961445124b5ff39412da32578e14e0d1f6afd6':
Remove the meaningless on Linux if_dl.h header.
Elliott Hughes [Tue, 12 Jun 2012 00:41:04 +0000 (17:41 -0700)]
am
c75491e2: Merge "Remove an obsolete jamfile."
* commit '
c75491e291586540c213ae088fc75b71fc4d3752':
Remove an obsolete jamfile.
Elliott Hughes [Mon, 11 Jun 2012 23:49:57 +0000 (16:49 -0700)]
Merge "Remove the meaningless on Linux if_dl.h header."
Nick Kralevich [Mon, 11 Jun 2012 22:50:57 +0000 (15:50 -0700)]
FORTIFY_SOURCE: add snprintf, vsnprintf
Add _FORTIFY_SOURCE support for snprintf, vsnprintf
At this time, we opt out of these protections for clang, as clang
does not implement __builtin_va_arg_pack().
http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc
Change-Id: I73ebe5ec8dad1dca8898a76d6afb693a25f75375
Elliott Hughes [Mon, 11 Jun 2012 23:29:46 +0000 (16:29 -0700)]
Merge "Remove an obsolete jamfile."
Elliott Hughes [Mon, 11 Jun 2012 23:17:45 +0000 (16:17 -0700)]
Remove an obsolete jamfile.
Was bionic ever built with jam? Weird!
Change-Id: Iea9a7af8bf46ee8319963e642da48e3bb49f6c60
Nick Kralevich [Mon, 11 Jun 2012 23:11:20 +0000 (16:11 -0700)]
Merge "inet_ntop: pass the size of tmp to snprintf()"
Nick Kralevich [Mon, 11 Jun 2012 21:29:30 +0000 (14:29 -0700)]
inet_ntop: pass the size of tmp to snprintf()
Fix runtime error when snprintf() FORTIFY_SOURCE protections are
applied. The size passed to snprintf() is larger than the tmp
buffer size, which results in a runtime assertion failure.
Even though the size passed to snprintf is larger than the buffer,
there's no danger of overwriting the buffer because of the format
string passed to snprintf.
Change-Id: I35f0217d25f3b9c6d04c5a76c3238759c235545a
Elliott Hughes [Mon, 11 Jun 2012 22:01:10 +0000 (15:01 -0700)]
Remove the meaningless on Linux if_dl.h header.
This was misleading 'configure' into thinking we actually support AF_LINK,
but we're Linux, so we don't, and we never implemented the functions we
declared here either.
Reported to AOSP by Jun-ya Kato.
(cherry-pick of
5056f1fad1187cd67729bb04ba72397d78256f03.)
Change-Id: Ic67f674d2221497c8166994812bb5fc7f0831066
Elliott Hughes [Mon, 11 Jun 2012 22:09:57 +0000 (15:09 -0700)]
Merge "Remove the meaningless on Linux if_dl.h header."
Elliott Hughes [Mon, 11 Jun 2012 22:01:10 +0000 (15:01 -0700)]
Remove the meaningless on Linux if_dl.h header.
This was misleading 'configure' into thinking we actually support AF_LINK,
but we're Linux, so we don't, and we never implemented the functions we
declared here either.
Reported to AOSP by Jun-ya Kato.
Change-Id: I111f9887f3812469b411b9cf5124d9dd624f19f7
Geremy Condra [Mon, 11 Jun 2012 19:17:12 +0000 (12:17 -0700)]
Merge "Added event logging for some spoofed DNS queries."
Geremy Condra [Mon, 11 Jun 2012 18:50:03 +0000 (11:50 -0700)]
Merge "Added actual event logging calls to the FORTIFY_SOURCE methods."
Geremy Condra [Sat, 9 Jun 2012 04:06:33 +0000 (21:06 -0700)]
Added event logging for some spoofed DNS queries.
Change-Id: I40909306e8cf922f1dd5a5685db89f732a709794
Geremy Condra [Fri, 8 Jun 2012 21:39:11 +0000 (14:39 -0700)]
Added actual event logging calls to the FORTIFY_SOURCE methods.
Change-Id: I3bf4fa8678c33187cb8ce4b75e666ddcd24403ab
The Android Open Source Project [Mon, 11 Jun 2012 16:23:11 +0000 (09:23 -0700)]
The Android Open Source Project [Mon, 11 Jun 2012 16:20:36 +0000 (09:20 -0700)]
Reconcile with jb-release
Change-Id: I7cbfbab55783f245c0854543843c2052c4c2e932
The Android Automerger [Mon, 11 Jun 2012 13:59:25 +0000 (06:59 -0700)]
merge in jb-release history after reset to jb-dev
Nick Kralevich [Thu, 7 Jun 2012 23:30:02 +0000 (16:30 -0700)]
_FORTIFY_SOURCE: check for integer overflows
Ensure that strcat / strncat check for integer overflows
when computing the length of the resulting string.
Change-Id: Ib806ad33a0d3b50876f384bc17787a28f0dddc37
Jeff Brown [Fri, 8 Jun 2012 22:33:31 +0000 (15:33 -0700)]
am
e4db460a: am
b7630f01: Use new debuggerd protocol.
* commit '
e4db460a54e4f024b83a7df9a3f9920d695da9f3':
Use new debuggerd protocol.
Jeff Brown [Fri, 8 Jun 2012 22:30:39 +0000 (15:30 -0700)]
am
b7630f01: Use new debuggerd protocol.
* commit '
b7630f018abc83261acf78e8cf9a88c1df72f7f5':
Use new debuggerd protocol.
Geremy Condra [Fri, 8 Jun 2012 19:17:11 +0000 (12:17 -0700)]
Merge "Adding event logging to libc."
Geremy Condra [Fri, 8 Jun 2012 00:45:06 +0000 (17:45 -0700)]
Adding event logging to libc.
I've basically just copied the relevant bits out of liblog and
EventLog.cpp. While this will let us do the uid logging we want
to address the concerns in
245c07027f78565858dd489eb0d94c3d48743e9d
it doesn't give us much else.
Change-Id: Icac6ff20bc0a3ade5927f6f76fedffe1ae6f8522
Nick Kralevich [Thu, 7 Jun 2012 21:30:20 +0000 (14:30 -0700)]
Merge "_FORTIFY_SOURCE: add memset / bzero support"
Nick Kralevich [Thu, 7 Jun 2012 21:01:26 +0000 (14:01 -0700)]
_FORTIFY_SOURCE: add memset / bzero support
Add _FORTIFY_SOURCE support for the following functions:
* memset
* bzero
Move the __BIONIC_FORTIFY_INLINE definition to cdefs.h so it
can be used from multiple header files.
Change-Id: Iead4d5e35de6ec97786d58ee12573f9b11135bb7
Elliott Hughes [Thu, 7 Jun 2012 18:43:47 +0000 (11:43 -0700)]
Merge "Support non-zero p_vaddr in first PT_LOAD segment"
The Android Open Source Project [Thu, 7 Jun 2012 14:51:59 +0000 (07:51 -0700)]
The Android Open Source Project [Thu, 7 Jun 2012 14:48:47 +0000 (07:48 -0700)]
Reconcile with jb-release
Change-Id: I2c8264a9a4e3299bca7fc01d67063993b6b1b886
Jeff Brown [Thu, 7 Jun 2012 01:37:48 +0000 (18:37 -0700)]
Use new debuggerd protocol.
Bug:
6615693
Change-Id: Ibfddc0de3fa2a882f7d0238ab797e5b29296b54b
Elliott Hughes [Wed, 6 Jun 2012 20:50:29 +0000 (13:50 -0700)]
am
d0c25027: am
2b89f1e3: Merge "Fix sysconf(_SC_NPROCESSORS_CONF) on ARM."
* commit '
d0c250271c983c3de282ff02bd2528e74ad8b5f1':
Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.
Elliott Hughes [Wed, 6 Jun 2012 20:48:07 +0000 (13:48 -0700)]
am
2b89f1e3: Merge "Fix sysconf(_SC_NPROCESSORS_CONF) on ARM."
* commit '
2b89f1e37df838e466d382fc602728930bad4c68':
Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.
Elliott Hughes [Wed, 6 Jun 2012 20:32:19 +0000 (13:32 -0700)]
Merge "Fix sysconf(_SC_NPROCESSORS_CONF) on ARM."
Elliott Hughes [Wed, 6 Jun 2012 19:04:38 +0000 (12:04 -0700)]
Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.
Bug: http://code.google.com/p/enh/issues/detail?id=33
Change-Id: I679b4cd888d362031042284e8edf01c5273a92aa
Elliott Hughes [Wed, 6 Jun 2012 18:37:25 +0000 (11:37 -0700)]
am
3069270d: am
c2bba24d: Merge "Give the timer_create SIGEV_THREAD helper threads sensible names."
* commit '
3069270d8641c7bb57aa308d8f90b4d2dcbf66fc':
Give the timer_create SIGEV_THREAD helper threads sensible names.
Elliott Hughes [Wed, 6 Jun 2012 18:35:32 +0000 (11:35 -0700)]
am
c2bba24d: Merge "Give the timer_create SIGEV_THREAD helper threads sensible names."
* commit '
c2bba24d0a6b906f00d7b9f20ac9d32d63bb2e9d':
Give the timer_create SIGEV_THREAD helper threads sensible names.
Elliott Hughes [Wed, 6 Jun 2012 17:44:31 +0000 (10:44 -0700)]
Merge "Give the timer_create SIGEV_THREAD helper threads sensible names."
Elliott Hughes [Wed, 6 Jun 2012 17:32:56 +0000 (10:32 -0700)]
Give the timer_create SIGEV_THREAD helper threads sensible names.
Bug:
6609676
Change-Id: I286b197c75beee4d9930b0973f2d7dd47c14e91c
Nick Kralevich [Wed, 6 Jun 2012 15:54:22 +0000 (08:54 -0700)]
Merge "arm: rewrite crtbegin* as C files."
Nick Kralevich [Mon, 4 Jun 2012 22:20:25 +0000 (15:20 -0700)]
libc: implement some FORTIFY_SOURCE functions
Add initial support for -D_FORTIFY_SOURCE to bionic for the
following functions:
* memcpy
* memmove
* strcpy
* strcat
* strncpy
* strncat
This change adds a new version of the above functions which passes
the size of the destination buffer to __builtin___*_chk.
If the compiler can determine, at compile time, that the destination
buffer is large enough, or the destination buffer can point to an object
of unknown size, then the check call is bypassed.
If the compiler can't make a compile time decision, then it calls
the __*_chk() function, which does a runtime buffer size check
These options are only enabled if the code is compiled with
-D_FORTIFY_SOURCE=1 or 2, and only when optimizations are enabled.
Please see
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
* http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
for additional details on FORTIFY_SOURCE.
Testing: Compiled the entire Android tree with -D_FORTIFY_SOURCE=1,
and verified that everything appears to be working properly.
Also created a test buffer overflow, and verified that it was
caught by this change.
Change-Id: I4fddb445bafe92b16845b22458d72e6dedd24fbc
Ji-Hwan Lee [Thu, 31 May 2012 11:20:36 +0000 (20:20 +0900)]
Support non-zero p_vaddr in first PT_LOAD segment
Before changing mmap() permission to PROT_NONE in alloc_mem_region(),
such libraries once worked with a bug that uses mmap'ed region outside of
memory region allocated by alloc_mem_region(). This possibly incurs
SIGSEGV because it can overwrite memory region of previously loaded
library, but it sometimes worked, depending on loading order.
After PROT_NONE, this caused SIGSEGV earlier during calculation of
si->phdr in load_library(), but this was fixed by:
75917c84d16c35b8fceff6977fa717a3de9ef65d Use mmap to read an ...
Now the behaviour is the same as before applying PROT_NONE in
alloc_mem_region().
This CL fixed the original issue, supporting shared libraries that have
non-zero p_vaddr in first (= with lowest p_vaddr) PT_LOAD segment.
Bug:
6561258
Change-Id: Ib6176dd3e44c4d99a340eb1cbd16fb037586b0bc
The Android Automerger [Sun, 3 Jun 2012 12:59:30 +0000 (05:59 -0700)]
merge in jb-release history after reset to jb-dev
Iliyan Malchev [Sat, 2 Jun 2012 15:35:07 +0000 (08:35 -0700)]
am
252a5c85: resolved conflicts for merge of
e1dd3c28 to jb-dev-plus-aosp
* commit '
252a5c854a08e89fc7337ea679220161fe4ea98f':
bionic: import heaptracker as chk_malloc
Iliyan Malchev [Sat, 2 Jun 2012 15:20:09 +0000 (08:20 -0700)]
am
f0ddaa2f: am
7d2e24eb: bionic: introduce libc.debug.malloc.program
* commit '
f0ddaa2fac00ac20059c0b2c142da9de2838a7b6':
bionic: introduce libc.debug.malloc.program
Iliyan Malchev [Sat, 2 Jun 2012 15:14:36 +0000 (08:14 -0700)]
resolved conflicts for merge of
e1dd3c28 to jb-dev-plus-aosp
Change-Id: I58b9c13d20771aa39b703ec05cbff8aeaad38fe8
Iliyan Malchev [Sat, 2 Jun 2012 02:03:06 +0000 (19:03 -0700)]
am
7d2e24eb: bionic: introduce libc.debug.malloc.program
* commit '
7d2e24eb167b6257f7935c7bd2023a708704ca1a':
bionic: introduce libc.debug.malloc.program
Iliyan Malchev [Tue, 29 May 2012 21:22:42 +0000 (14:22 -0700)]
bionic: import heaptracker as chk_malloc
This patch is a rewrite of libc.debug.malloc = 10 (chk_malloc). It provides
the same features as the original (poison freed memory, detect heap overruns
and underruns), except that it provides more debugging information whenever it
detects a problem.
In addition to the original features, the new chk_malloc() implementation
detects multiple frees within a given range of the last N allocations, N being
configurable via the system property libc.debug.malloc.backlog.
Finally, this patch keeps track of all outstanding memory allocations. On
program exit, we walk that list and report each outstanding allocation.
(There is support (not enabled) for a scanner thread periodically walks over
the list of outstanding allocations as well as the backlog of recently-freed
allocations, checking for heap-usage errors.)
Feature overview:
1) memory leaks
2) multiple frees
3) use after free
4) overrun
Implementation:
-- for each allocation, there is a:
1) stack trace at the time the allocation is made
2) if the memory is freed, there is also a stack trace at the point
3) a front and rear guard (fence)
4) the stack traces are kept together with the allocation
-- the following lists and maintained
1) all outstanding memory allocations
3) a backlog of allocations what are freed; when you call free(), instead of
actually freed, the allocation is moved to this backlog;
4) when the backlog of allocations gets full, the oldest entry gets evicted
from it; at that point, the allocation is checked for overruns or
use-after-free errors, and then actually freed.
5) when the program exits, the list of outstanding allocations and the
backlog are inspected for errors, then freed;
To use this, set the following system properties before running the process or
processes you want to inspect:
libc.malloc.debug.backlog # defaults to 100
libc.malloc.debug 10
When a problem is detected, you will see the following on logcat for a multiple
free:
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 BYTES MULTIPLY FREED!
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc
4009647c /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 FIRST FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc
40096490 /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 NOW BEING FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c6ac /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc
400964a0 /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
The following for a heap overrun and underrun:
E/libc ( 7233): +++ REAR GUARD MISMATCH [10, 11)
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 HAS A CORRUPTED REAR GUARD
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc
40096438 /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc
40096462 /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 HAS A CORRUPTED FRONT GUARD
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc
400964ba /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc
400964e4 /system/bin/malloctest
E/libc ( 7233): #04 pc
00016f24 /system/lib/libc.so
The following for a memory leak:
E/libc ( 7233): +++ THERE ARE 1 LEAKED ALLOCATIONS
E/libc ( 7233): +++ DELETING 4096 BYTES OF LEAKED MEMORY AT 0x404b95e8 (1 REMAINING)
E/libc ( 7233): +++ ALLOCATION 0x404b95e8 SIZE 4096 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc
0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc
0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc
00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc
0001bc94 /system/lib/libc.so
E/libc ( 7233): #04 pc
0001edf6 /system/lib/libc.so
E/libc ( 7233): #05 pc
0001b80a /system/lib/libc.so
E/libc ( 7233): #06 pc
0001c086 /system/lib/libc.so
E/libc ( 7233): #07 pc
40096402 /system/bin/malloctest
E/libc ( 7233): #08 pc
00016f24 /system/lib/libc.so
Change-Id: Ic440e9d05a01e2ea86b25e8998714e88bc2d16e0
Signed-off-by: Iliyan Malchev <malchev@google.com>
Nick Kralevich [Thu, 31 May 2012 18:40:10 +0000 (11:40 -0700)]
arm: rewrite crtbegin* as C files.
Rewrite
crtbegin.S -> crtbegin.c
crtbegin_so.S -> crtbegin_so.c
This change allows us to generate PIC code without relying
on text relocations.
As a consequence of this rewrite, also rewrite
__dso_handle.S -> __dso_handle.c
__dso_handle_so.S -> __dso_handle_so.c
atexit.S -> atexit.c
In crtbegin.c _start, place the __PREINIT_ARRAY__, __INIT_ARRAY__,
__FINI_ARRAY__, and __CTOR_LIST__ variables onto the stack, instead of
passing a pointer to the text section of the binary.
This change appears sorta wonky, as I attempted to preserve,
as much as possible, the structure of the original assembly.
As a result, you have C files including other C files, and other
programming uglyness.
Result: This change reduces the number of files with text-relocations
from 315 to 19 on my Android build.
Before:
$ scanelf -aR $OUT/system | grep TEXTREL | wc -l
315
After:
$ scanelf -aR $OUT/system | grep TEXTREL | wc -l
19
Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
The Android Automerger [Thu, 31 May 2012 13:59:25 +0000 (06:59 -0700)]
merge in jb-release history after reset to jb-dev
Iliyan Malchev [Tue, 29 May 2012 23:46:17 +0000 (16:46 -0700)]
bionic: introduce libc.debug.malloc.program
libc.debug.malloc.program provides an additional level of control over which
processes to enable libc.debug.malloc functionality for. The string value of
libc.debug.malloc.program is matched against the program name; if the value of
libc.debug.malloc.program is a substring of the program name, then malloc debug
is applied to that program at whatever level libc.debug.malloc specifies.
If lib.debug.malloc.program is not specified, then libc.debug.malloc has the
same effect as before.
For example, to enable libc.deubug.malloc = 10 only to the mediaserver, do the
following:
adb root # necessary for setprop
adb setprop libc.debug.malloc.program mediaserver
adb setprop libc.debug.malloc 10
adb kill -9 $(pid mediaserver)
Change-Id: I6f01c12f033c8e2e015d73025369d7f1685ba200
Signed-off-by: Iliyan Malchev <malchev@google.com>
Nick Kralevich [Wed, 30 May 2012 20:29:58 +0000 (13:29 -0700)]
Merge "crtbegin: eliminate duplicate code"
Nick Kralevich [Wed, 30 May 2012 18:45:12 +0000 (11:45 -0700)]
crtbegin: eliminate duplicate code
crtbegin_dynamic and crtbegin_static are essentially identical,
minus a few trivial differences (comments and whitespace).
Eliminate duplicates.
Change-Id: Ic9fae6bc9695004974493b53bfc07cd3bb904480
Geremy Condra [Wed, 30 May 2012 18:11:33 +0000 (11:11 -0700)]
am
5a095ef2: am
03539a36: Merge "Ensure that the port number and TXID are properly randomized." into jb-dev
* commit '
5a095ef28716b54f86d9c1727b9a2493ba775255':
Ensure that the port number and TXID are properly randomized.
Geremy Condra [Wed, 30 May 2012 18:09:05 +0000 (11:09 -0700)]
am
03539a36: Merge "Ensure that the port number and TXID are properly randomized." into jb-dev
* commit '
03539a36b634bdfa61c06277cf25e0ca8e3105ba':
Ensure that the port number and TXID are properly randomized.
Geremy Condra [Wed, 30 May 2012 18:06:54 +0000 (11:06 -0700)]
Merge "Ensure that the port number and TXID are properly randomized." into jb-dev
The Android Open Source Project [Tue, 29 May 2012 16:41:51 +0000 (09:41 -0700)]
am
cb9ba3c8: Reconcile with jb-release
* commit '
cb9ba3c88a97f34784559a55317ff5970d4c4dba':
Print the corrupted address passed to free().
The Android Open Source Project [Tue, 29 May 2012 16:39:17 +0000 (09:39 -0700)]
Reconcile with jb-release
Change-Id: Id0b365ef6729dc36b88193f1675d3819e56bd426
Elliott Hughes [Fri, 25 May 2012 22:11:35 +0000 (15:11 -0700)]
Merge "Use mmap to read an initial ELF header of library"
Ji-Hwan Lee [Fri, 25 May 2012 13:36:00 +0000 (22:36 +0900)]
Use mmap to read an initial ELF header of library
Also, fixes SIGSEV during calculation of si->phdr in load_library(),
which is caused by accessing PHDR area, which is not guaranteed to be
loaded.
Note that this usually does not happen because program header area is
covered by immediately following PT_LOAD entry. But it does not hold
always.
Bug:
6561258
Change-Id: Ie376253c773b5420279ca89044e81b1aad5a5736
Ben Cheng [Thu, 24 May 2012 23:56:53 +0000 (16:56 -0700)]
Print the corrupted address passed to free().
For example:
@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x5c3bfbd0
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2942
The addr=0x5c3bfbd0 part is new.
Change-Id: I8670144b2b0a3a6182384150d762c97dfee5452f
Ben Cheng [Fri, 25 May 2012 00:23:43 +0000 (17:23 -0700)]
am
d7b60b20: am
c84ff11d: Print the corrupted address passed to free().
* commit '
d7b60b207be79513b99faf2ef576db333f9c7a78':
Print the corrupted address passed to free().
Ben Cheng [Fri, 25 May 2012 00:21:03 +0000 (17:21 -0700)]
am
c84ff11d: Print the corrupted address passed to free().
* commit '
c84ff11dad26435dc5760bceda18e8f1175a6061':
Print the corrupted address passed to free().
Ben Cheng [Thu, 24 May 2012 23:56:53 +0000 (16:56 -0700)]
Print the corrupted address passed to free().
For example:
@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x5c3bfbd0
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2942
The addr=0x5c3bfbd0 part is new.
Change-Id: I8670144b2b0a3a6182384150d762c97dfee5452f
Geremy Condra [Mon, 21 May 2012 21:20:59 +0000 (14:20 -0700)]
Ensure that the port number and TXID are properly randomized.
This fix reads from /dev/urandom to get the required entropy.
Bug:
6535492
Change-Id: Ibc2fec3f71a67607b608ad9b767b0b6504993c1d
Jean-Baptiste Queru [Mon, 21 May 2012 19:41:30 +0000 (12:41 -0700)]
am
d155ba57: am
c7882ab2: Merge "bionic: add clean kernel header ucontext.h"
* commit '
d155ba57a32ce3182d8a5b79ff27bc5e7fa55df9':
bionic: add clean kernel header ucontext.h