Commit graph

2935 commits

Author SHA1 Message Date
Elliott Hughes
75064c177f Initialize __progname correctly.
setprogname() does a basename, but we were initializing __progname
directly. Stop doing that, and add some tests.

Test: treehugger
Change-Id: I06f306ade4161b2f0c7e314a3b1b30c9420117b7
2020-01-23 08:28:48 -08:00
Elliott Hughes
22fb267ad6 Reimplement realpath.
Use O_PATH like musl to let the kernel do the hard work, rather than the
traditional BSD manual scheme.

Also add the most obvious missing tests from reading the man page, plus
a non-obvious test for deleted files.

Bug: http://b/131435126
Test: treehugger
Change-Id: Ie8a8986fea55f045952a81afee377ce8288a49d5
2020-01-22 18:30:50 -08:00
Nicolas Geoffray
5c9efd1d66 Merge "Revert "Add tagged pointers to bionic."" 2020-01-21 13:57:45 +00:00
Nicolas Geoffray
ce4c42e09f Revert "Add tagged pointers to bionic."
This reverts commit 43d5f9d4dd.

Bug: 135754954
Bug: 147147490

Exempt-From-Owner-Approval: clean revert

Reason for revert: Breaks ART gtest, see:
https://ci.chromium.org/p/art/builders/ci/angler-armv8-non-gen-cc/561

The crash happens on mprotect of a page, the test crashes with ENOMEM.

Change-Id: I52eea1abbfaf8d8e2226f92d30aa55aba3810528
2020-01-21 13:57:26 +00:00
Dan Willemsen
a547762ae3 Merge "Convert more bionic tests to Android.bp" 2020-01-21 04:52:16 +00:00
Mitch Phillips
3460b6c265 Merge "Add tagged pointers to bionic." 2020-01-20 23:31:27 +00:00
Dan Willemsen
4bcfe3c330 Convert more bionic tests to Android.bp
Bug: 122332847
Bug: 130734182
Test: mmm bionic/tests; same files installed before & after
Test: m cts; same files in cts before & after
Test: `objdump -x <files> | grep NEEDED` is identical
Test: `objdump -x <files> | grep RUNPATH` difference make sense
      (additional lib64 entries from soong, minimal reorder)
Test: treehugger
Change-Id: I6eea4c3f9c0040efeba64e2b47c7b573767cd386
2020-01-16 10:12:46 -08:00
Christopher Ferris
f5421dde7f Merge "Add new malloc align tests." 2020-01-16 17:20:26 +00:00
Ryan Savitski
b72fed164e Merge "allow for heapprofd's signal to be multiplexed" 2020-01-16 16:04:08 +00:00
Mitch Phillips
43d5f9d4dd Add tagged pointers to bionic.
This patch introduces tagged pointers to bionic. We add a static tag to
all pointers on arm64 compatible platforms (needs requisite
top-byte-ignore hardware feature and relevant kernel patches).

We dynamically detect TBI-compatible devices (a device with the TBI feature and
kernel support) at process start time, and insert an implementation-dependent
tag into the top byte of the pointer for all heap allocations. We then check
that the tag has not been truncated when deallocating the memory.

If an application incorrectly writes to the top byte of the pointer, we
terminate the process at time of detection. This will allow MTE-incompatible
applications to be caught early.

Bug: 135754954
Bug: 147147490

Test: cd bionic && atest .
Change-Id: I6e5b809fc81f55dd517f845eaf20f3c0ebd4d86e
2020-01-15 15:03:00 -08:00
Ryan Savitski
175c8867b0 allow for heapprofd's signal to be multiplexed
This patch refactors heapprofd_malloc to make it easier to reuse the
reserved signal for multiple purposes. We define a new generic signal
handler for profilers, which dispatches to more specific logic based on
the signal's payload (si_value).

The profiler signal handler is installed during libc preinit, after
malloc initialization (so races against synchronous heapprofd
initialization need not be considered). In terms of code organization, I
copied the existing approach with a loosely referenced function in
bionic_globals.h. Do tell if you'd rather a different approach here.

The profileability of a process is quite tied to the malloc
files/interfaces in bionic - in particular, it's set through
android_mallopt. I do not change that, but instead introduce a new
android_mallopt option to be able to query profileability of the
process (which is now used by the new profiler signal handler). As part
of that, gZygoteChildProfileable is moved from heapprofd_malloc to
common (alongside gZygoteChild).

I've removed the masking and reraising of the heapprofd signal when
racing against malloc_limit init. We're ok with taking a simpler
approach and dropping the heapprofd signal in such an unlikely race.

Note: this requires a corresponding change in heapprofd to use sigqueue()
instead of kill(), as the latter leaves the si_value uninitialized(?) on
the receiving side.

Bug: 144281346
Change-Id: I93bb2e82cff5870e5ca499cf86439860aca9dfa5
2020-01-15 22:55:03 +00:00
Christopher Ferris
f32494c985 Add new malloc align tests.
Bug: 146576216

Test: Ran the test on jemalloc and glibc.
Test: Ran the test on scudo and verified that failed without the align
Test: change.
Change-Id: I31a96f8672c6bce2423210300288a13df1eda42a
2020-01-15 09:22:21 -08:00
Steven Moreland
06f39d36a4 stack_protector_DeathTest: work w/ local reorder
Before, the helper method for this test had two local variables:
    char buf[128];
    volatile char* p;

Then the test wrote zeros into the buffer and one past the buffer end.
This relied on the fact that the compiler constructed the stack frame
with 'p' first and then the buffer (and also optimized away the 'size'
variable).

However, some compiler options (namely -ftrivial-auto-var-init=pattern)
result in the stack frame being reordered so that 'p' is actually after
buf, and the test cannot pass.

Fixes: 132780819
Test: bionic-unit-tests-static (w/ w/o flag)
Change-Id: Icc87c02add211c2afb7c96ae22701ec27990364c
2020-01-14 14:11:16 -08:00
Elliott Hughes
5dc31300ff Explicitly test printf %s with nullptr.
I haven't found a bug, but tests are good.

Bug: https://github.com/landley/toybox/issues/163
Change-Id: I57149800099abc699cc841b69a5a72aeac7c2bcc
2020-01-07 08:48:10 -08:00
Elliott Hughes
95c6cd753f Stop using the __ANDROID_API_x__ constants.
Historically we've made a few mistakes where they haven't matched the
right number. And most non-Googlers are much more familiar with the
numbers, so it seems to make sense to rely more on them. Especially in
header files, which we actually expect real people to have to read from
time to time.

Test: treehugger
Change-Id: I0d4a97454ee108de1d32f21df285315c5488d886
2019-12-20 13:26:14 -08:00
Evgeny Eltsin
4ea64e91e8 Merge "Fix dlext.ns_anonymous test for native bridge" 2019-12-17 19:22:04 +00:00
Evgeny Eltsin
ad865d7b3d Fix dlext.ns_anonymous test for native bridge
The executable flag might not be present for the executable segment
if the code is being handled by native bridge implementation. Old
heuristics for this case was to assume first segment is executable.
This doesn't stand any more. Instead, look for segment that contains
the function test is going to call.

Test: bionic-unit-tests --gtest_filter=dlext.ns_anonymous
Change-Id: I960bebba86e225d739b73f6d093e145fff17b4a8
2019-12-17 18:54:17 +01:00
Evgeny Eltsin
4d9264c593 Fix signal.sigwait64_SIGRTMIN test
'kill(pid, sig)' sends signal to arbitrary thread within a process, thus
test was occasionally sending signal to the killing thread, not to the
waiting thread. Use 'tgkill(pid, tid, sig)' instead.

Test: bionic-unit-tests --gtest_filter=signal.sigwait64_SIGRTMIN
Change-Id: I80377295e2362cb87eb4fb4de2489c51c520ea77
2019-12-17 18:03:06 +01:00
Evgeny Eltsin
b29173cd64 Increase sleep time in sigwait64_SIGRTMIN test
With previous sleep time, if unlucky, newly started thread can send
signal before main thread starts sigwait.

Test: bionic-unit-tests --gtest_filter=signal.sigwait64_SIGRTMIN
Change-Id: I63d7825a695988e388903c7951e2435cb69773a1
2019-12-16 17:01:11 +01:00
Ryan Prichard
d4299c3f0f Merge changes I052011f2,I40f42464
* changes:
  dl_test: update error message
  dl_test: use GTEST_SKIP() in a few places
2019-12-11 20:32:04 +00:00
Evgeny Eltsin
bd1c63065e Fix sys_ptrace_test feature check on arm64
The code was checking PTRACE_GETREGSET output even in case of error.
This seems not correct. Though ptrace can still write some output in
case of EINVAL, implementation should still check updated iov_len before
reading it.

Change the code to avoid checking output in case of error at all.

Test: bionic-unit-tests --gtest_filter=sys_ptrace.watchpoint_stress
Change-Id: I7b1ca18ac64f81055ff89f56b453aff0ce8e1057
2019-12-11 15:42:04 +01:00
Ryan Prichard
0f67214c50 dl_test: update error message
Bug: http://b/145998177
Test: atest CtsBionicTestCases on a non-debuggable, user build
Change-Id: I052011f274edc331aa63fc6cd7666af2aebc2ad0
2019-12-10 14:50:11 -08:00
Ryan Prichard
55f9a24acc dl_test: use GTEST_SKIP() in a few places
Bug: none
Test: bionic unit tests
Change-Id: I40f42464359576ffbd55d0f56347c6c45daf73f9
2019-12-10 14:45:20 -08:00
Elliott Hughes
9416e02757 Merge "Sync with upstream OpenBSD strstr()." 2019-12-02 20:12:56 +00:00
Dmytro Chystiakov
595c381841 Fix linker path for emulated architecture
dl#exec_linker* tests are failing on devices with emulated
architecture due to hardcoded path to linker.

Test: bionic-unit-tests --gtest_filter=dl.exec_linker*
Bug: b/141914915

Change-Id: Id6d8d3ee7114e70b07e44034aa62dce0a3e0760e
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-11-26 15:32:02 +01:00
Elliott Hughes
c6b38aefa7 Sync with upstream OpenBSD strstr().
Bug: http://b/124855136
Test: treehugger
Change-Id: I6cbeb82bc0e418f50e6c171ac4e38e335c448db8
2019-11-22 11:16:23 -08:00
George Burgess IV
8a0cdb15a1 fortify: allow diagnostics without run-time checks (attempt #2)
In configs like ASAN, we can't use _chk functions. This CL builds off of
previous work to allow us to still emit diagnostics in conditions like
these.

Wasn't 100% sure what a good test story would look like here. Opinions
appreciated.

Bug: 141267932
Test: checkbuild on internal-master. TreeHugger for x86_64.
Change-Id: I65da9ecc9903d51a09f740e38ab413b9beaeed88
2019-11-19 14:20:26 -08:00
Elliott Hughes
db602e8a47 sysconf(_SC_ARG_MAX): go back to imitating the kernel.
For reasons explained in the code comment, go back to roughly our old
code. The "new" tests are just the old tests resurrected.

This also passes the current toybox xargs tests, which were the
motivation for going back on our earlier decision.

Test: bionic and toybox tests
Change-Id: I33cbcc04107efe81fdbc8166dc9ae844e471173e
2019-11-15 09:24:35 -08:00
Raman Tenneti
afe44cc483 Merge "Revert "Revert "Make system property reads wait-free""" 2019-11-12 20:43:29 +00:00
Raman Tenneti
b481a2e743 Revert "Revert "Make system property reads wait-free""
This reverts commit de39d9242a.

Reason for revert: This revert is not needed

Change-Id: I34af8e5d75c724f6c4066fafbfc6bc7d58377601
2019-11-12 20:41:55 +00:00
Raman Tenneti
1b28efa2d1 Merge "Revert "Make system property reads wait-free"" 2019-11-12 18:26:48 +00:00
Raman Tenneti
de39d9242a Revert "Make system property reads wait-free"
This reverts commit 0cf90556de.

Reason for revert: Device boot failures - 144355953

Change-Id: Icd4fc8c7a1d06d688a6d37e6f1c1aa45563f711b
2019-11-12 18:24:06 +00:00
Treehugger Robot
985e678516 Merge "Make system property reads wait-free" 2019-11-12 17:14:30 +00:00
Daniel Colascione
0cf90556de Make system property reads wait-free
Right now, when we read a system property, we first (assuming we've
already looked up the property's prop_info) read the property's serial
number; if we find that the low bit (the dirty bit) in the serial
number is set, we futex-wait for that serial number to become
non-dirty. By doing so, we spare readers from seeing partially-updated
property values if they race with the property service's non-atomic
memcpy to the property value slot. (The futex-wait here isn't
essential to the algorithm: spinning while dirty would suffice,
although it'd be somewhat less efficient.)

The problem with this approach is that readers can wait on the
property service process, potentially causing delays due to scheduling
variance. Property reads are not guaranteed to complete in finite time
right now.

This change makes property reads wait-free and ensures that they
complete in finite time in all cases. In the new approach, we prevent
value tearing by backing up each property we're about to modify and
directing readers to the backup copy if they try to read a property
with the dirty bit set.

(The wait freedom is limited to the case of readers racing against
*one* property update. A writer can still delay readers by rapidly
updating a property --- but after this change, readers can't hang due
to PID 1 scheduling delays.)

I considered adding explicit atomic access to short property values,
but between binary compatibility with the existing property database
and the need to carefully handle transitions of property values
between "short" (compatible with atomics) and "long" (incompatible
with atomics) length domains, I figured the complexity wasn't worth it
and that making property reads wait-free would be adequate.

Test: boots
Bug: 143561649
Change-Id: Ifd3108aedba5a4b157b66af6ca0a4ed084bd5982
2019-11-11 11:17:00 -08:00
Treehugger Robot
28fb781ef7 Merge "linker: add more context to link failure error." 2019-11-09 00:13:31 +00:00
George Burgess IV
2fead5fd89 Merge "Revert "fortify: allow diagnostics without run-time checks"" 2019-11-07 07:10:38 +00:00
George Burgess IV
f359548bf1 Revert "fortify: allow diagnostics without run-time checks"
This reverts commit d7e11b8853.

Reason for revert: Breaks aosp_x86_64-eng. Will look into it and
unbreak when it's not almost midnight. :)

Change-Id: I21f76efe4d19c70d0b14630e441376d359a45b49
2019-11-07 07:07:38 +00:00
Treehugger Robot
d1dcb72882 Merge "fortify: allow diagnostics without run-time checks" 2019-11-07 01:34:11 +00:00
Christopher Ferris
7a3a5d8cd7 Merge "Fix allocations escaping malloc debug." 2019-11-06 23:31:33 +00:00
Tom Cherry
b18158c3c9 Merge changes I01d061c4,I2e3f6ee7
* changes:
  Check that __system_property_set() doesn't leak FDs
  clang-format: Add IncludeBlocks: Preserve
2019-11-06 21:54:00 +00:00
Christopher Ferris
ff88fb0d3a Fix allocations escaping malloc debug.
When using a FILE object for some malloc debug functions, calling
fprintf will trigger an allocation to be put in the object. The problem
is that these allocations were not allocated by the malloc debug
wrapper and they get freed during the fclose as if they are malloc
debug allocation. In most cases, the code will detect the bad pointer
and leak the memory, but it might also cause a crash.

The fix is to avoid using fprintf so that no allocations are made
in the object that survive and need to be freed in the fclose call.

Change the MallocXmlElem.h to use a file decsriptor not a FILE object.

Add new unit and system tests to detect this case.

Bug: 143742907

Test: Ran unit and system tests.
Test: Ran bionic unit tests.
Change-Id: I524392de822a29483aa5be8f14c680e70033eba2
2019-11-06 10:42:42 -08:00
Elliott Hughes
9a09137b0e Merge "Limit threads in pthread_leak#detach for low power devices." 2019-11-06 16:00:48 +00:00
Josh Gao
1626957666 linker: add more context to link failure error.
This change makes it easier to diagnose mistakes in linker
configuration that result in a library being accidentally loaded in
multiple namespaces without its dependencies available everywhere.

Test: manually tested the error message
Test: bionic-unit-tests
Change-Id: I03a20507f8fc902c2445a7fbbf59767ffffd5ebf
2019-11-05 13:45:54 -08:00
Tom Cherry
fd7216cc19 Check that __system_property_set() doesn't leak FDs
Bug: 143936364
Test: fail when b/143936364 repros
Test: pass when b/143936364 is fixed
Change-Id: I01d061c4fb4f37b0300ef418a19c88003038092c
2019-11-05 12:33:33 -08:00
George Burgess IV
d7e11b8853 fortify: allow diagnostics without run-time checks
In configs like ASAN, we can't use _chk functions. This CL builds off of
previous work to allow us to still emit diagnostics in conditions like
these.

Wasn't 100% sure what a good test story would look like here. Opinions
appreciated.

Bug: 141267932
Test: checkbuild on internal-master
Change-Id: I8d4f77d7b086a8128a18a0a0389243d7fa05b00f
2019-11-01 16:25:55 -07:00
Peter Collingbourne
609d6ec416 Merge "Adopt GNU calling convention for ifunc resolvers." 2019-10-29 17:19:33 +00:00
Elliott Hughes
ca3f8e4901 sleep/usleep: switch to trivial implementations.
Upstream keeps rearranging the deckchairs for these, so let's just
switch to the [roughly] one-liners rather than track that...

Test: treehugger
Change-Id: If655cf7a7f316657de44d41fadd43a8c55ee6f23
2019-10-28 22:25:02 -07:00
Peter Collingbourne
e949195f64 Adopt GNU calling convention for ifunc resolvers.
In order for an ifunc resolver to detect the presence of certain CPU features,
access to getauxval(AT_HWCAP) or getauxval(AT_HWCAP2) may be required. In order
for getauxval() to work, it needs to access the pointer to the auxiliary vector
stored by the linker in the libc shared globals data structure. Accessing the
shared globals requires libc to call the __libc_shared_globals() function
exported by the linker. However, in order to call this function, libc must
be fully relocated, which is not guaranteed to be the case at the point when
ifunc resolvers are called.

glibc solves this problem by passing the values of getauxval(AT_HWCAP)
(and getauxval(AT_HWCAP2) on aarch64) as arguments to the ifunc resolver.
Since this seems to be not only the most straightforward way to solve the
problem but also improves our compatibility with glibc, we adopt their
calling convention.

This change is ABI compatible with old resolvers because the arguments are
passed in registers, so the old resolvers will simply ignore the new arguments.

Bug: 135772972
Change-Id: Ie65bd6e7067f0c878df3d348c815fda61dc12de2
2019-10-28 20:20:29 -07:00
Dmytro Chystiakov
6e36dd2c15 Limit threads in pthread_leak#detach for low power devices.
This patch decreases created threads to 50 (instead of 90)
on devices with 2 cores CPU. It is a second decrease as this
test case started to fail on same devices after kernel uprev

Bug: b/142210680
Test: Run CtsBionic module on 2 core device with command
	"run cts -m CtsBionicTestCases

Change-Id: I4f73363b342b38c92d64aaf213071f899e5b52ac
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-10-25 16:12:47 -07:00
Christopher Ferris
ee0ce440fd Add bionic-stress-tests.
I plan to add tests to this test binary that take a long time to run.

The first is a malloc test that demonstrates that jemalloc appears
to be leaking memory slowly over time.

Test: Ran the bionic-stress-tests on host and verified it runs forever,
Test: but doesn't display RSS/VSS data.
Test: Ran the bionic-stress-tests on a taimen and verified it runs forever,
Test: and does display RSS/VSS data.
Change-Id: Ic612e4181ffea898d4d83af097939cd517a180ee
2019-10-22 22:49:06 +00:00
Christopher Ferris
89b658c265 Only get stats for relevant maps.
Scudo creates a large map on 64 bit which can cause a slow down trying
to get the usage stats for all maps. Since the test only really cares
about a small subset of maps, only get the usage stats for those maps.

Test: Ran unit tests on scudo and jemalloc based systems.
Change-Id: Iba3cff1487ca304083aac323a3971b9f939f5c11
2019-10-10 15:10:40 -07:00
Christopher Ferris
87a10ac108 Merge "Add support for scudo." 2019-10-10 16:56:21 +00:00
Christopher Ferris
85169658e1 Add support for scudo.
As the first pass, the malloc_info for scudo doesn't return anything.
This feature is hardly ever used, so this seems fine for the first
revision.

Bug: 137795072

Test: Ran unit tests on a taimen using scudo and a taimen using jemalloc.
Change-Id: I675386ae17ba5505c27bd9da12c60242d795464a
2019-10-09 18:54:53 -07:00
Elliott Hughes
a4959aa6f8 Reimplement the <ctype.h> is* functions.
Following on from the towlower()/towupper() changes, add benchmarks for
most of <ctype.h>, rewrite the tests to cover the entire defined range
for all of these functions, and then reimplement most of the functions.

The old table-based implementation is mostly a bad idea on modern
hardware, with only ispunct() showing a significant benefit compared to
any other way I could think of writing it, and isalnum() a marginal but
still convincingly genuine benefit.

My new benchmarks make an effort to test an example from each relevant
range of characters to avoid, say, accidentally optimizing the behavior
of `isalnum('0')` at the expense of `isalnum('z')`.

Interestingly, clang is able to generate what I believe to be the
optimal implementations from the most readable code, which is
impressive. It certainly matched or beat all my attempts to be clever!

The BSD table-based implementations made a special case of EOF despite
having a `_ctype_` table that's offset by 1 to include EOF at index 0.
I'm not sure why they didn't take advantage of that, but removing the
explicit check for EOF measurably improves the generated code on arm and
arm64, so even the two functions that still use the table benefit from
this rewrite.

Here are the benchmark results:

arm64 before:
  BM_ctype_isalnum_n                 3.73 ns         3.73 ns    183727137
  BM_ctype_isalnum_y1                3.82 ns         3.81 ns    186383058
  BM_ctype_isalnum_y2                3.73 ns         3.72 ns    187809830
  BM_ctype_isalnum_y3                3.78 ns         3.77 ns    181383055
  BM_ctype_isalpha_n                 3.75 ns         3.75 ns    189453927
  BM_ctype_isalpha_y1                3.76 ns         3.75 ns    184854043
  BM_ctype_isalpha_y2                4.32 ns         3.78 ns    186326931
  BM_ctype_isascii_n                 2.49 ns         2.48 ns    275583822
  BM_ctype_isascii_y                 2.51 ns         2.51 ns    282123915
  BM_ctype_isblank_n                 3.11 ns         3.10 ns    220472044
  BM_ctype_isblank_y1                3.20 ns         3.19 ns    226088868
  BM_ctype_isblank_y2                3.11 ns         3.11 ns    220809122
  BM_ctype_iscntrl_n                 3.79 ns         3.78 ns    188719938
  BM_ctype_iscntrl_y1                3.72 ns         3.71 ns    186209237
  BM_ctype_iscntrl_y2                3.80 ns         3.80 ns    184315749
  BM_ctype_isdigit_n                 3.76 ns         3.74 ns    188334682
  BM_ctype_isdigit_y                 3.78 ns         3.77 ns    186249335
  BM_ctype_isgraph_n                 3.99 ns         3.98 ns    177814143
  BM_ctype_isgraph_y1                3.98 ns         3.95 ns    175140090
  BM_ctype_isgraph_y2                4.01 ns         4.00 ns    178320453
  BM_ctype_isgraph_y3                3.96 ns         3.95 ns    175412814
  BM_ctype_isgraph_y4                4.01 ns         4.00 ns    175711174
  BM_ctype_islower_n                 3.75 ns         3.74 ns    188604818
  BM_ctype_islower_y                 3.79 ns         3.78 ns    154738238
  BM_ctype_isprint_n                 3.96 ns         3.95 ns    177607734
  BM_ctype_isprint_y1                3.94 ns         3.93 ns    174877244
  BM_ctype_isprint_y2                4.02 ns         4.01 ns    178206135
  BM_ctype_isprint_y3                3.94 ns         3.93 ns    175959069
  BM_ctype_isprint_y4                4.03 ns         4.02 ns    176158314
  BM_ctype_isprint_y5                3.95 ns         3.94 ns    178745462
  BM_ctype_ispunct_n                 3.78 ns         3.77 ns    184727184
  BM_ctype_ispunct_y                 3.76 ns         3.75 ns    187947503
  BM_ctype_isspace_n                 3.74 ns         3.74 ns    185300285
  BM_ctype_isspace_y1                3.77 ns         3.76 ns    187202066
  BM_ctype_isspace_y2                3.73 ns         3.73 ns    184105959
  BM_ctype_isupper_n                 3.81 ns         3.80 ns    185038761
  BM_ctype_isupper_y                 3.71 ns         3.71 ns    185885793
  BM_ctype_isxdigit_n                3.79 ns         3.79 ns    184965673
  BM_ctype_isxdigit_y1               3.76 ns         3.75 ns    188251672
  BM_ctype_isxdigit_y2               3.79 ns         3.78 ns    184187481
  BM_ctype_isxdigit_y3               3.77 ns         3.76 ns    187635540

arm64 after:
  BM_ctype_isalnum_n                 3.37 ns         3.37 ns    205613810
  BM_ctype_isalnum_y1                3.40 ns         3.39 ns    204806361
  BM_ctype_isalnum_y2                3.43 ns         3.43 ns    205066077
  BM_ctype_isalnum_y3                3.50 ns         3.50 ns    200057128
  BM_ctype_isalpha_n                 2.97 ns         2.97 ns    236084076
  BM_ctype_isalpha_y1                2.97 ns         2.97 ns    236083626
  BM_ctype_isalpha_y2                2.97 ns         2.97 ns    236084246
  BM_ctype_isascii_n                 2.55 ns         2.55 ns    272879994
  BM_ctype_isascii_y                 2.46 ns         2.45 ns    286522323
  BM_ctype_isblank_n                 3.18 ns         3.18 ns    220431175
  BM_ctype_isblank_y1                3.18 ns         3.18 ns    220345602
  BM_ctype_isblank_y2                3.18 ns         3.18 ns    220308509
  BM_ctype_iscntrl_n                 3.10 ns         3.10 ns    220344270
  BM_ctype_iscntrl_y1                3.10 ns         3.07 ns    228973615
  BM_ctype_iscntrl_y2                3.07 ns         3.07 ns    229192626
  BM_ctype_isdigit_n                 3.07 ns         3.07 ns    228925676
  BM_ctype_isdigit_y                 3.07 ns         3.07 ns    229182934
  BM_ctype_isgraph_n                 2.66 ns         2.66 ns    264268737
  BM_ctype_isgraph_y1                2.66 ns         2.66 ns    264445277
  BM_ctype_isgraph_y2                2.66 ns         2.66 ns    264327427
  BM_ctype_isgraph_y3                2.66 ns         2.66 ns    264427480
  BM_ctype_isgraph_y4                2.66 ns         2.66 ns    264155250
  BM_ctype_islower_n                 2.66 ns         2.66 ns    264421600
  BM_ctype_islower_y                 2.66 ns         2.66 ns    264341148
  BM_ctype_isprint_n                 2.66 ns         2.66 ns    264415198
  BM_ctype_isprint_y1                2.66 ns         2.66 ns    264268793
  BM_ctype_isprint_y2                2.66 ns         2.66 ns    264419205
  BM_ctype_isprint_y3                2.66 ns         2.66 ns    264205886
  BM_ctype_isprint_y4                2.66 ns         2.66 ns    264440797
  BM_ctype_isprint_y5                2.72 ns         2.72 ns    264333293
  BM_ctype_ispunct_n                 3.52 ns         3.51 ns    198956572
  BM_ctype_ispunct_y                 3.38 ns         3.38 ns    201661792
  BM_ctype_isspace_n                 3.39 ns         3.39 ns    206896620
  BM_ctype_isspace_y1                3.39 ns         3.39 ns    206569020
  BM_ctype_isspace_y2                3.39 ns         3.39 ns    206564415
  BM_ctype_isupper_n                 2.76 ns         2.75 ns    254227134
  BM_ctype_isupper_y                 2.76 ns         2.75 ns    254235314
  BM_ctype_isxdigit_n                3.60 ns         3.60 ns    194418653
  BM_ctype_isxdigit_y1               2.97 ns         2.97 ns    236082424
  BM_ctype_isxdigit_y2               3.48 ns         3.48 ns    200390011
  BM_ctype_isxdigit_y3               3.48 ns         3.48 ns    202255815

arm32 before:
  BM_ctype_isalnum_n                 4.77 ns         4.76 ns    129230464
  BM_ctype_isalnum_y1                4.88 ns         4.87 ns    147939321
  BM_ctype_isalnum_y2                4.74 ns         4.73 ns    145508054
  BM_ctype_isalnum_y3                4.81 ns         4.80 ns    144968914
  BM_ctype_isalpha_n                 4.80 ns         4.79 ns    148262579
  BM_ctype_isalpha_y1                4.74 ns         4.73 ns    145061326
  BM_ctype_isalpha_y2                4.83 ns         4.82 ns    147642546
  BM_ctype_isascii_n                 3.74 ns         3.72 ns    186711139
  BM_ctype_isascii_y                 3.79 ns         3.78 ns    183654780
  BM_ctype_isblank_n                 4.20 ns         4.19 ns    169733252
  BM_ctype_isblank_y1                4.19 ns         4.18 ns    165713363
  BM_ctype_isblank_y2                4.22 ns         4.21 ns    168776265
  BM_ctype_iscntrl_n                 4.75 ns         4.74 ns    145417484
  BM_ctype_iscntrl_y1                4.82 ns         4.81 ns    146283250
  BM_ctype_iscntrl_y2                4.79 ns         4.78 ns    148662453
  BM_ctype_isdigit_n                 4.77 ns         4.76 ns    145789210
  BM_ctype_isdigit_y                 4.84 ns         4.84 ns    146909458
  BM_ctype_isgraph_n                 4.72 ns         4.71 ns    145874663
  BM_ctype_isgraph_y1                4.86 ns         4.85 ns    142037606
  BM_ctype_isgraph_y2                4.79 ns         4.78 ns    145109612
  BM_ctype_isgraph_y3                4.75 ns         4.75 ns    144829039
  BM_ctype_isgraph_y4                4.86 ns         4.85 ns    146769899
  BM_ctype_islower_n                 4.76 ns         4.75 ns    147537637
  BM_ctype_islower_y                 4.79 ns         4.78 ns    145648017
  BM_ctype_isprint_n                 4.82 ns         4.81 ns    147154780
  BM_ctype_isprint_y1                4.76 ns         4.76 ns    145117604
  BM_ctype_isprint_y2                4.87 ns         4.86 ns    145801406
  BM_ctype_isprint_y3                4.79 ns         4.78 ns    148043446
  BM_ctype_isprint_y4                4.77 ns         4.76 ns    145157619
  BM_ctype_isprint_y5                4.91 ns         4.90 ns    147810800
  BM_ctype_ispunct_n                 4.74 ns         4.73 ns    145588611
  BM_ctype_ispunct_y                 4.82 ns         4.81 ns    144065436
  BM_ctype_isspace_n                 4.78 ns         4.77 ns    147153712
  BM_ctype_isspace_y1                4.73 ns         4.72 ns    145252863
  BM_ctype_isspace_y2                4.84 ns         4.83 ns    148615797
  BM_ctype_isupper_n                 4.75 ns         4.74 ns    148276631
  BM_ctype_isupper_y                 4.80 ns         4.79 ns    145529893
  BM_ctype_isxdigit_n                4.78 ns         4.77 ns    147271646
  BM_ctype_isxdigit_y1               4.74 ns         4.74 ns    145142209
  BM_ctype_isxdigit_y2               4.83 ns         4.82 ns    146398497
  BM_ctype_isxdigit_y3               4.78 ns         4.77 ns    147617686

arm32 after:
  BM_ctype_isalnum_n                 4.35 ns         4.35 ns    161086146
  BM_ctype_isalnum_y1                4.36 ns         4.35 ns    160961111
  BM_ctype_isalnum_y2                4.36 ns         4.36 ns    160733210
  BM_ctype_isalnum_y3                4.35 ns         4.35 ns    160897524
  BM_ctype_isalpha_n                 3.67 ns         3.67 ns    189377208
  BM_ctype_isalpha_y1                3.68 ns         3.67 ns    189438146
  BM_ctype_isalpha_y2                3.75 ns         3.69 ns    190971186
  BM_ctype_isascii_n                 3.69 ns         3.68 ns    191029191
  BM_ctype_isascii_y                 3.68 ns         3.68 ns    191011817
  BM_ctype_isblank_n                 4.09 ns         4.09 ns    171887541
  BM_ctype_isblank_y1                4.09 ns         4.09 ns    171829345
  BM_ctype_isblank_y2                4.08 ns         4.07 ns    170585590
  BM_ctype_iscntrl_n                 4.08 ns         4.07 ns    170614383
  BM_ctype_iscntrl_y1                4.13 ns         4.11 ns    171495899
  BM_ctype_iscntrl_y2                4.19 ns         4.18 ns    165255578
  BM_ctype_isdigit_n                 4.25 ns         4.24 ns    165237008
  BM_ctype_isdigit_y                 4.24 ns         4.24 ns    165256149
  BM_ctype_isgraph_n                 3.82 ns         3.81 ns    183610114
  BM_ctype_isgraph_y1                3.82 ns         3.81 ns    183614131
  BM_ctype_isgraph_y2                3.82 ns         3.81 ns    183616840
  BM_ctype_isgraph_y3                3.79 ns         3.79 ns    183620182
  BM_ctype_isgraph_y4                3.82 ns         3.81 ns    185740009
  BM_ctype_islower_n                 3.75 ns         3.74 ns    183619502
  BM_ctype_islower_y                 3.68 ns         3.68 ns    190999901
  BM_ctype_isprint_n                 3.69 ns         3.68 ns    190899544
  BM_ctype_isprint_y1                3.68 ns         3.67 ns    190192384
  BM_ctype_isprint_y2                3.67 ns         3.67 ns    189351466
  BM_ctype_isprint_y3                3.67 ns         3.67 ns    189430348
  BM_ctype_isprint_y4                3.68 ns         3.68 ns    189430161
  BM_ctype_isprint_y5                3.69 ns         3.68 ns    190962419
  BM_ctype_ispunct_n                 4.14 ns         4.14 ns    171034861
  BM_ctype_ispunct_y                 4.19 ns         4.19 ns    168308152
  BM_ctype_isspace_n                 4.50 ns         4.50 ns    156250887
  BM_ctype_isspace_y1                4.48 ns         4.48 ns    155124476
  BM_ctype_isspace_y2                4.50 ns         4.50 ns    155077504
  BM_ctype_isupper_n                 3.68 ns         3.68 ns    191020583
  BM_ctype_isupper_y                 3.68 ns         3.68 ns    191015669
  BM_ctype_isxdigit_n                4.50 ns         4.50 ns    156276745
  BM_ctype_isxdigit_y1               3.28 ns         3.27 ns    214729725
  BM_ctype_isxdigit_y2               4.48 ns         4.48 ns    155265129
  BM_ctype_isxdigit_y3               4.48 ns         4.48 ns    155216846

I've also corrected a small mistake in the documentation for isxdigit().

Test: tests and benchmarks
Change-Id: I4a77859f826c3fc8f0e327e847886882f29ec4a3
2019-10-08 12:04:09 -07:00
Christopher Ferris
88b2f0d8f0 Add support for scudo.
Bug: 137795072

Test: Unit tests pass on jemalloc and scudo.
Change-Id: I764cdad2507d322ff36dd5d28bd8ff9719601e6a
2019-10-02 12:48:23 -07:00
Christopher Ferris
c5d3a4348a Make tls related header files platform accessible.
There are places in frameworks and art code that directly included
private bionic header files. Move these files to the new platform
include files.

This change also moves the __get_tls.h header file to tls.h and includes
the tls defines header so that there is a single header that platform
code can use to get __get_tls and the defines.

Also, simplify the visibility rules for platform includes.

Bug: 141560639

Test: Builds and bionic unit tests pass.
Change-Id: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
Merged-In: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
(cherry picked from commit 44631c919a)
2019-09-27 12:14:24 -07:00
Christopher Ferris
f97dcc15e8 Merge "Revert "Temporarily disable some clock_getres tests."" 2019-09-24 19:19:28 +00:00
Christopher Ferris
a9dfe1c352 Revert "Temporarily disable some clock_getres tests."
This reverts commit 8eba2a59ac.

Reason for revert: The kernel update has been reverted.

Change-Id: I21d9ac3c319b8c6e8546a0b40c5646c5610cc8c5
2019-09-24 16:20:17 +00:00
Christopher Ferris
849f0db7ca Merge "Temporarily disable some clock_getres tests." 2019-09-24 14:12:13 +00:00
Christopher Ferris
8eba2a59ac Temporarily disable some clock_getres tests.
A kernel update broke three clock_getres tests, so disable
them while the kernel is fixed.

Bug: 141515847

Test: All tests pass on cuttlefish.
Change-Id: I7db789b2b8ba0bc5f8b13bb06e85711031735925
2019-09-23 18:44:22 -07:00
Christopher Ferris
103b998a52 Stop executing if skip occurs.
Bug: 141358530

Test: Forced a skip and verified it registers as a skip.
Change-Id: I9915c67ebae4389a26f28e16375ad4a41f3e4837
2019-09-23 09:41:13 -07:00
George Burgess IV
8a4414ef9c fortify: remove pragma diagnostic error from tests
This was necessary because we weren't doing -Werror=fortify-source
everywhere. As of I2715ea411ef067f801534dab4d306fef5431f290, we should
be doing this.

Bug: 131861088
Test: mma
Change-Id: I00d499938ae24c3870760470576d6be603fbecd1
2019-09-19 15:23:45 -07:00
Treehugger Robot
e6c3f0628c Merge "fortify: account for new clang diagnostics" 2019-09-17 20:11:51 +00:00
George Burgess IV
36926f4ca8 fortify: account for new clang diagnostics
Clang recently grew its own diagnostics for memcpy and such. These are
generally higher-quality than what we can do with diagnose_if, since
clang is happy to include e.g., sizes of things per-callsite. Move to
those instead where applicable.

Bug: 131861088, 123644155
Test: blueline internal-master checkbuild; treehugger
Change-Id: I701f5a8b247ba2948ca47fdc60ff5198b564c03e
2019-09-16 12:48:04 -07:00
Christopher Ferris
2b0638ef29 Make bionic_malloc.h a platform header.
Instead of having platform directories directly include the
private header, create a platform header directory and export it.

Bug: 130763340

Test: Builds.
Change-Id: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
Merged-In: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
(cherry picked from commit 8f582ef2f8)
2019-09-16 12:27:33 -07:00
Christopher Ferris
f0e70113d5 Merge "Add EFD_SEMAPHORE flag for eventfd."
am: add3a4ae70

Change-Id: I5508cec132fa1c8b79d41f39231e26fde17bba2f
2019-09-03 12:45:26 -07:00
Christopher Ferris
2c4cb0d760 Add EFD_SEMAPHORE flag for eventfd.
Add a test for the new flag and add a test for the EFD_CLOEXEC flag.

Test: New unit tests pass on glibc and target.
Change-Id: Ib7a6ea4aadbd67ba8a523b6114a49fb8d6a43f12
2019-09-03 09:35:51 -07:00
Christopher Ferris
5b8d0757f1 Merge "Use ReadMapFileAsyncSafe in malloc_iterate tests."
am: 8bccbb01e7

Change-Id: I6eab952fb46f1f3e0a9661c1e25f4ef98dea0d09
2019-08-24 01:22:13 -07:00
Ryan Prichard
f62547a4ee Merge "Add additional dl_phdr_info fields"
am: 665e98edf7

Change-Id: I3c1ed6c9f53ef2a348de69481498299577437780
2019-08-24 01:18:27 -07:00
Christopher Ferris
8bccbb01e7 Merge "Use ReadMapFileAsyncSafe in malloc_iterate tests." 2019-08-24 04:12:42 +00:00
Ryan Prichard
665e98edf7 Merge "Add additional dl_phdr_info fields" 2019-08-23 20:45:54 +00:00
Christopher Ferris
8ea85afde5 Use ReadMapFileAsyncSafe in malloc_iterate tests.
This avoids issues where an allocation could create a map while trying
to check data from the maps and running malloc_iterate.

Bug: 137795072

Test: Runs in unit tests.
Change-Id: If8509845d86dd9d002aeac3aa9278fbcf026af17
2019-08-23 10:07:31 -07:00
Ryan Prichard
a2e83ab348 Add additional dl_phdr_info fields
Previously, Bionic's dl_phdr_info only included the first four
dl_iterate_phdr fields. Several other libc's have these additional fields:

    unsigned long long dlpi_adds -- incremented when a library is loaded
    unsigned long long dlpi_subs -- incremented when a library is unloaded
    size_t dlpi_tls_modid -- TLS module ID
    void* dlpi_tls_data -- pointer to current thread's TLS block or NULL

These extra fields are also exposed by glibc, musl, and FreeBSD. The
unwinder in libgcc.a, linked into shipping Android DSOs, has a
PC->eh_frame cache that activates if dl_phdr_info has the dlpi_adds and
dlpi_subs fields (indicated at run-time by a sufficiently-large size
argument to the callback).

Bug: https://github.com/android-ndk/ndk/issues/1062
Test: bionic unit tests
Change-Id: I6f0bab548cf8c828af2ddab9eb01c5c6d70cd81f
2019-08-22 12:43:17 -07:00
Yi Kong
d5da35bc84 Merge changes from topic "clang-r365631-switch-over"
am: 436af3d55b

Change-Id: I116f6b040d47ec6f4fca540322651f7d59305cc9
2019-08-22 11:57:14 -07:00
Tom Cherry
0dc903ee6a stdatomic_test: always use bits/stdatomic.h
am: 32b5f4e16b

Change-Id: I8978d456b4e513913f999552908c342a5f98b4d1
2019-08-22 11:56:59 -07:00
Yi Kong
2da8962f77 Adapt tests due to the new Clang fortify-source warning
am: bf67ea5426

Change-Id: I997e180413e9f647ca6671ce23ef6e6618cd806e
2019-08-22 11:56:24 -07:00
Yi Kong
436af3d55b Merge changes from topic "clang-r365631-switch-over"
* changes:
  Fix segment gap test
  stdatomic_test: always use bits/stdatomic.h
  Adapt tests due to the new Clang fortify-source warning
2019-08-22 18:35:54 +00:00
Yi Kong
e39a51bfd4 Fix segment gap test
The test starts failing in the upcoming lld update. The root cause is
that no relro section is specified by the linker script, and the orphan
placement algorithm decides to place them after .text which is a
misaligned place.

Test: bionic-unit-tests
Bug: 139089152
Bug: 131328001
Change-Id: I2140d8a9fd7c712f1d31a541a3b4a10788385e98
2019-08-17 22:41:25 +00:00
Peter Collingbourne
752b619240 Merge "Fix a few bionic test failures caused by hwasan global instrumentation."
am: 3952113d90

Change-Id: I17d6e9c5448b081c6833af6fc1ec247c997bfc59
2019-08-16 10:56:35 -07:00
Peter Collingbourne
3952113d90 Merge "Fix a few bionic test failures caused by hwasan global instrumentation." 2019-08-16 17:26:05 +00:00
Peter Collingbourne
191ecdc49b Fix a few bionic test failures caused by hwasan global instrumentation.
The call to the load hook needs to be moved before the call to link_image()
because the latter calls ifunc resolvers which might access global
variables. This fixes a bunch of ifunc tests.

The dlfcn.segment_gap test is currently failing. One problem is that the name
of the .bss.end_of_gap section changes as a result of global instrumentation.
Add some wildcards in so that we match both names. The other problem seems
to be the same as b/139089152.

It turns out that we need to untag pointers in a few more places. Since we have
quite a few of these now it seems worth creating a function for it.

Test: bionic-unit-tests
Change-Id: I44e2b0904faacdda7cc0c5e844ffc09de01dea2d
2019-08-15 09:21:34 -07:00
Tom Cherry
32b5f4e16b stdatomic_test: always use bits/stdatomic.h
Host includes are updated now, so we always must include
bits/stdatomic.h

Bug: 137876753
Bug: 138701943
Test: not yet
Change-Id: Ib2ce34ae5dace8f9a114fa8c04f864cd7f41a5d9
2019-08-14 07:08:28 +00:00
Josh Gao
6f844f936f Merge "leak_test: use tgkill to check if threads are alive."
am: 80d85f72dd

Change-Id: I2cb534827a3afa286305d093d498a497c688a3c0
2019-08-13 18:48:23 -07:00
Josh Gao
253ef12f50 leak_test: use tgkill to check if threads are alive.
If one of our threads exits and a new process shows up with the same
tid, we would previously loop until that process exits, leading to
flakiness in tests.

Also fix use of uninitialized memory that happens when threads_count !=
kThreadCount.

Bug: http://b/139315254
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter="pthread_leak.detach" on cuttlefish
Change-Id: I2aad7f3f105aeba87c3929bfce53ef08e1484b2d
2019-08-13 16:13:39 -07:00
Elliott Hughes
15ae87b2fb Merge "Add memfd_create(2) and mlock2(2)."
am: da32ff104b

Change-Id: I2609877a7984e137a785614b6eff01d728472b76
2019-08-06 10:40:22 -07:00
Elliott Hughes
3d24d2b088 Add memfd_create(2) and mlock2(2).
These are old enough now that the latest devices will have kernels that
support them.

Also add basic doc comments to <sys/mman.h>.

Test: treehugger
Change-Id: I1b5ff5db0b6270f5c374287cac1d6a751a0259f5
2019-08-05 16:31:08 -07:00
Yi Kong
bf67ea5426 Adapt tests due to the new Clang fortify-source warning
https://reviews.llvm.org/D58797 added several new compile time
_FORTIFY_SOURCE diagnostics. This broke clang_fortify_tests:

FAILED: out/target/product/walleye/obj/STATIC_LIBRARIES/bionic-compile-time-tests2-clang++_intermediates/clang_fortify_tests.o
error: 'warning' diagnostics seen but not expected:
  Line 159: 'memcpy' will always overflow; destination buffer has size 8, but size argument is 9
  Line 161: 'memmove' will always overflow; destination buffer has size 8, but size argument is 9
  Line 165: 'memset' will always overflow; destination buffer has size 8, but size argument is 9
  Line 183: 'strncpy' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 185: 'stpncpy' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 189: 'strncat' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 227: 'strncpy' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 232: 'stpncpy' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 242: 'strncat' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 490: 'snprintf' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 495: 'vsnprintf' size argument is too large; destination buffer has size 8, but size argument is 9
error: 'note' diagnostics seen but not expected:
  File bionic/libc/include/bits/fortify/fcntl.h Line 50: 'open' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 102: 'open64' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 75: 'openat' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 121: 'openat64' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/stdio.h Line 68: 'sprintf' has been explicitly marked unavailable here
16 errors generated.

Bug: 131328001
Bug: 138701853
Test: Build with r365631 toolchain
Change-Id: I103ecb7b3abcf4b5cfc4f36ccab69e03d0976275
2019-08-05 11:48:47 -07:00
Elliott Hughes
0dc203a547 Merge "Add renameat2."
am: fd56f55419

Change-Id: I6843edd14527e6029271718b076ad5cbc94fee45
2019-08-02 15:19:42 -07:00
Elliott Hughes
05b675e8bf Add renameat2.
Bug: http://b/127675384
Test: new tests
Change-Id: Ia2e3d5679180391ca98e62fa429fa11cbf167507
2019-08-02 09:09:59 -07:00
Tom Cherry
52de5d1a70 Merge "Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)"
am: 6b2532e19a

Change-Id: I78c3d5fb79a63edb71553cd1ebe554511361e6c5
2019-07-19 11:36:49 -07:00
Tom Cherry
d9be229581 Merge "Load /etc/{passwd,group} from all partitions"
am: 5a8482ef8f

Change-Id: I86b764124ba8d926d97f42387af2f28889f5b1be
2019-07-19 11:33:50 -07:00
Tom Cherry
6b2532e19a Merge "Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)" 2019-07-19 18:01:06 +00:00
Tom Cherry
5a8482ef8f Merge "Load /etc/{passwd,group} from all partitions" 2019-07-19 18:00:41 +00:00
Tom Cherry
76e2b15ad4 Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)
The previous check was causing some problems with platform builds
using the NDK.  The new check is more accurate.

Move the C definitions from stdatomic.h to bits/stdatomic.h since
with the new check, we no longer can use the #undef trick to test
them.

Test: build platform NDK with stdatomic.h in pthread.h header
Test: stdatomic bionic-unit-tests
Change-Id: Ia0bc3cc8344f2ba4e6e55a52248fb6efee799d1d
2019-07-18 13:57:39 -07:00
Tom Cherry
50940c55d2 Merge "Fix pthread_cond_clockwait() when cond is initialized with CLOCK_MONOTONIC"
am: 09ecb00b86

Change-Id: I100818d326b59f335b7f3c78024f29821db35bf7
2019-07-17 14:30:26 -07:00
Tom Cherry
800c1a9707 Fix pthread_cond_clockwait() when cond is initialized with CLOCK_MONOTONIC
A bit of over-reliance on implementing pthread_cond_clockwait() in
terms of existing functions ended up with a bug that if the condition
variable was initialized to use CLOCK_MONOTONIC, then
pthread_cond_clockwait() would do the wrong thing.

This change corrects that and adds a test for this case.

Test: new and existing tests pthread_cond unit tests
Change-Id: I708d5dfbef95a67678db56dceda011f2f8fd1c5c
2019-07-17 10:46:47 -07:00
Tom Cherry
32531b709a Merge "Implement new clock wait functions"
am: 7e958d0ce0

Change-Id: I05e1801d8355aa941102bfc9e382afdea77cbea5
2019-07-15 16:49:22 -07:00
Tom Cherry
69010802d0 Implement new clock wait functions
pthread_cond_clockwait
pthread_mutex_clocklock
pthread_rwlock_clockrdlock
pthread_rwlock_clockwrlock
sem_clockwait

Bug: 35756266
Test: new unit tests
Change-Id: I71bd25eeec6476134b368d5bdf2f729d0bba595e
2019-07-15 09:06:19 -07:00
Tom Cherry
777b34dcc3 Load /etc/{passwd,group} from all partitions
Note that unlike the oem_ range that is used for the vendor
partitions, we do not create oem_<n> entries for these new reserved
ranges; they will only appear in getpwent()/getgrent() if there is an
entry in the corresponding passwd/group file.

Bug: 73062966
Test: can load AIDs from partitions other than vendor
Test: bionic-unit-tests
Change-Id: Ifcbbf202894adff948eaaba2a59e25c993611140
2019-07-11 10:31:02 -07:00
dimitry
63b261096b Merge "Remove unused dependency to libandoridicu"
am: 7d961a16e9

Change-Id: I415fd796093c80fd8964546ebdccca52ff7764e2
2019-07-10 10:23:53 -07:00
dimitry
29fbf6fdd2 Remove unused dependency to libandoridicu
Test: mmma -j42 bionic/
Change-Id: I6049dbea5a55523758649370396a6a5bfb09462f
2019-07-10 15:50:29 +02:00
Elliott Hughes
ae4c2f06e6 Merge "Stop using grep -P."
am: 7d10422499

Change-Id: Ie773bb9a364e9c1a38dd43181e1e1232bb671fcd
2019-07-09 09:10:06 -07:00
Elliott Hughes
165a8c6653 Stop using grep -P.
This might let us get to using toybox grep for the build faster than if
we have to implement PCRE support.

Test: builds
Change-Id: Idaf24cfefbf18fdc442871f24fe4fe9b2152359a
2019-07-08 15:03:19 -07:00
Elliott Hughes
6684b7e877 Merge "The time#clock test has been a bit flaky." am: 05407d81f8
am: 81c16d9770

Change-Id: I5b3af7337a3a49394d3e36a8212189eeeeec09b2
2019-06-21 08:25:43 -07:00
Treehugger Robot
05407d81f8 Merge "The time#clock test has been a bit flaky." 2019-06-21 08:06:28 +00:00
George Burgess IV
3d508099d1 Merge changes I33957ad4,I02f8f87d,Iba04e486 am: 36bc922772
am: cb1b6d43bc

Change-Id: I3247830e8cfad5685e6312c2aa15d3b6f908900b
2019-06-20 17:53:14 -07:00
George Burgess IV
36bc922772 Merge changes I33957ad4,I02f8f87d,Iba04e486
* changes:
  fortify: replace bzero/bcmp defines
  fortify: add __mempcpy_chk
  fortify: fix overflow checks in unistd
2019-06-21 00:18:44 +00:00
Elliott Hughes
5ae1628455 The time#clock test has been a bit flaky.
Bump our expectation up to <5ms.

Test: treehugger
Change-Id: Ic1a704043efb55fc295482583fc7cc23d18cfbf4
2019-06-20 14:35:49 -07:00
Christopher Ferris
4cc1b28358 Merge "Run pvalloc/valloc tests in unsupported envs." am: b42a488512
am: e99522f6e2

Change-Id: Ifabb27e5fd9a8cc96cd3fbd5ed5be01f3a4f1761
2019-06-20 14:05:45 -07:00
George Burgess IV
8934620ceb Merge changes I557309b3,If5f47e0e am: 3bdeae781f
am: 39cc17bb47

Change-Id: I506872bb5b1e155255a29e3400fa5365adc5d0fc
2019-06-20 14:03:25 -07:00
Christopher Ferris
a24a75d372 Merge "Change pvalloc call to valloc in test." am: 8fef03f609
am: 3912fff5f0

Change-Id: I69e916d2d4bf896297d1b42394022d5720277124
2019-06-20 13:56:48 -07:00
George Burgess IV
261b7f4867 fortify: replace bzero/bcmp defines
__builtin_*_chk will emit warnings when things are trivially broken.
Emitting errors instead is probably better (and we can be a bit smarter
about how we emit code for trivially safe cases.)

Bug: 131861088
Test: checkbuild + bionic-unit-tests on blueline
Change-Id: I33957ad419922d0760304758ecb9bc8ad33e0b64
2019-06-20 13:05:23 -07:00
Christopher Ferris
b42a488512 Merge "Run pvalloc/valloc tests in unsupported envs." 2019-06-20 19:04:51 +00:00
George Burgess IV
3bdeae781f Merge changes I557309b3,If5f47e0e
* changes:
  fortify: add even more warnings
  fortify: fix up a few diagnostics; add __wur to realpath
2019-06-20 17:20:52 +00:00
Christopher Ferris
804cebe1c6 Run pvalloc/valloc tests in unsupported envs.
In order for cts to enumerate tests, even tests that are not supported
need to run and be skipped. Make this true for pvalloc/valloc
tests.

Change-Id: I863a179ee6810824a7117f44cc9aa3f86d01eb5b
Test: Ran tests in 32 bit and 64 bit and verified tests are skipped in
Test: 64 bit and run properly in 32 bit.
2019-06-20 08:57:07 -07:00
Christopher Ferris
d5ab0a5706 Change pvalloc call to valloc in test.
Found by kostyak, the call should have been valloc, not pvalloc.

Test: Ran unit tests on taimen.
Change-Id: I676b8f3f8051be6768e2ad87b579844560b4f619
2019-06-19 12:03:57 -07:00
George Burgess IV
63c81d1635 Merge changes I80475ff4,I894aec99 am: 1b297b9e5a
am: 7b850f4437

Change-Id: I5f40826cc5170fed4cce67a1bd30be054a9bb159
2019-06-18 11:28:08 -07:00
George Burgess IV
849c0b9f51 fortify: add __mempcpy_chk
Bug: 131861088
Test: mma + bionic-unit-tests on blueline
Change-Id: I02f8f87d5db0ba5fecec410da32f6ffa2c98ef57
2019-06-13 23:29:37 -07:00
George Burgess IV
26d25a22e2 fortify: add even more warnings
Bug: 131861088
Test: mma
Change-Id: I557309b3e25b54321ee1fe0207f18b6e840bf76e
2019-06-13 23:26:02 -07:00
George Burgess IV
2356c93d39 fortify: add bit checking for open(at)?64 functions
This also adds _2-variants for these functions, for extra glorious
checking

Bug: 131861088
Test: mma
Change-Id: I80475ff4bb220c0c47894e9532426f53412f176f
2019-06-13 23:26:02 -07:00
George Burgess IV
74519e7aa5 fortify: fix overflow checks in unistd
We should only be calling _real versions of the functions that use this
if the input size is verifiably <= SSIZE_MAX. Otherwise, just fall
through to _chk and let that handle it.

Bug: 131861088
Test: mma && bionic-unit-tests
Change-Id: Iba04e486ef91ea1b3539ab6df6260429264e66b4
2019-06-13 23:26:02 -07:00
George Burgess IV
8c0ec114c5 fortify: fix up a few diagnostics; add __wur to realpath
As it says on the box.

Since realpath isn't a function definition, any attributes it provides
here just add to the "regular" realpath.

__wur is being added to realpath because it returns NULL on failure, and
the contents of the input buffer are undefined in that case. A blueline
checkbuild showed 0 complaints about this new __wur, so it seems
harmless to add.

Bug: 131861088
Test: mma
Change-Id: If5f47e0e290d86df69c0888711e29775c390fca4
2019-06-13 23:26:02 -07:00
George Burgess IV
77f99aaf58 fortify: add diagnostics for str* functions
This CL allows us to diagnose string functions that get an explicit size
passed into them, and string functions that are trivially misused.

Bug: 131861088
Test: mma
Change-Id: I894aec99420a75c6474cfd7d5010f0cf2f10ab21
2019-06-13 23:26:02 -07:00
George Burgess IV
6de7ab2ac3 Merge "fortify: fix tests on x86_64" am: 1eb5976d75
am: 03b28211c0

Change-Id: I0106c1b4f121f821ee4b05de980879588df5fdd6
2019-06-13 15:52:38 -07:00
George Burgess IV
06bb4ce8de fortify: fix tests on x86_64
My declval hack failed on x86_64 with:

```
substitution failure [with T = __va_list_tag [1]]: function cannot
return array type '__va_list_tag [1]'
```

...Because the type of va_list is compiler magic, it's fine for it to be
whatever the compiler wants it to be. Thankfully, pointers to arrays can
be returned, so let's use those instead.

Bug: 135210098
Test: mma on aosp_blueline-eng and aosp_x86_64-eng; the latter was
      failing before this patch.

Change-Id: Iefd57c0f8e823653fd70633fb6ee75cfc0022430
2019-06-13 15:18:16 -07:00
George Burgess IV
5bfadfef0e Merge "fortify: import tests from Chrome OS" am: 9894ec4596
am: 74946ef407

Change-Id: I29e1ee1fedd7c59904d99c96e77287b17c196d38
2019-06-13 13:41:57 -07:00
George Burgess IV
9a2741010a fortify: import tests from Chrome OS
Chrome OS has a fairly extensive FORTIFY test suite for both
compile-time and run-time diagnostics. It covers tons of edge cases, and
conveniently centralizes diagnostic and death testing.

A fair amount of it has been ifdef'ed out, since Bionic doesn't yet
diagnose (or crash on) some of these things. The intent is to explicitly
declare defeat on the things we don't care to FORTIFY, and slowly fix
the rest in easier-to-digest CLs.

Once that's done, we might be able to look into retiring some of the
FORTIFY testing that we don't share with the CrOS folks.

Bug: 131861088
Test: mma + bionic-unit-tests on blueline

Change-Id: I16734ea0769e03cf658ef10532d64f28fdb36a89
2019-06-10 12:46:49 -07:00
Mitch Phillips
44c29535cc Merge "Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'." 2019-05-30 22:24:06 +00:00
Tom Cherry
ab7987d124 Merge "Make 'app' users/groups more accurate" am: f6bac59447
am: c7499d17c1

Change-Id: I6176d544109bb75760e4014b2d39b32816400169
2019-05-30 13:44:46 -07:00
Mitch Phillips
dfde0eeee1 Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'.
Cleanup of references to 'coverage' in build files. Part of a larger
cleanup to make fuzzing work again in the Android build tree.

Also fixed a test issue with emulated TLS with the new changes, and
removed libc.so fuzzer support until a linked bug is fixed
(b/132640749).

Bug: 121042685
Test: With all patches in the bug merged: mmma bionic
Change-Id: I592352fe9210ff811a2660a88cbbfe48d70a1e57
Merged-In: I592352fe9210ff811a2660a88cbbfe48d70a1e57
2019-05-30 16:49:13 +00:00
Tom Cherry
6b116d1bbf Make 'app' users/groups more accurate
In an attempt to make bionic's reporting of users and groups more
accurate, this change makes the user / group functions do the
following:

1) Fail to query a uid/gid for a secondary user when the uid/gid
   doesn't exist.  Currently bionic would return successfully but with
   a empty string for the name.
2) Fail to query a platform uid/gid, except a limited pre-allocated
   set for a secondary user, as these are not used by second users.
3) Fail to query uids for all users for the GID-only app ranges:
   CACHE_GID, EXT_GID, EXT_CACHE_GID, SHARED_GID.
4) Fail to query gids in SHARED_GID range for secondary users, as
   these GIDs are only allocated for the first user.
5) Use "u#_a#_ext" and u#_a#_ext_cache" for EXT_GID and EXT_CACHE_GID
   ranges.  This both allows querying based on these names and
   returning these names for the appropriate uids/gids.

This also consolidates the tests for better readability.

Test: these unit tests, boot

Change-Id: I59a1af0792e7806d423439582e56ce7f9f801c94
2019-05-29 15:54:50 -07:00
Mitch Phillips
2f1bdef5fb Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'.
Cleanup of references to 'coverage' in build files. Part of a larger
cleanup to make fuzzing work again in the Android build tree.

Also fixed a test issue with emulated TLS with the new changes, and
removed libc.so fuzzer support until a linked bug is fixed
(b/132640749).

Bug: 121042685
Test: With all patches in the bug merged: mmma bionic

This is the qt-dev-plus-aosp cherrypick of aosp/954684. See the AOSP
commit for further information.

Change-Id: I592352fe9210ff811a2660a88cbbfe48d70a1e57
2019-05-28 15:44:18 -07:00
Elliott Hughes
e0ee594385 Merge "Move off the Next ZipString overload." am: 0c0afe17e9
am: 1bb5ac584b

Change-Id: I1e35353c86aad938ca4b1f30ed5edb9a9b516330
2019-05-23 13:10:52 -07:00
Elliott Hughes
127a706581 Move off the Next ZipString overload.
Bug: http://b/129068177
Test: treehugger
Change-Id: I83840c2ffd6cdede8cb34b4ec168427a43e1daf7
2019-05-22 18:50:53 -07:00
Tom Cherry
ab36addb14 Merge "pwd/grp: fix pwd _r reentrancy, new tests, clean up" am: e1276ba538
am: 3395d23ad6

Change-Id: Ifc13d405c34c8bf721662d42a82265a77d5bde87
2019-05-21 15:42:48 -07:00
Treehugger Robot
e1276ba538 Merge "pwd/grp: fix pwd _r reentrancy, new tests, clean up" 2019-05-21 18:29:33 +00:00
Dmytro Chystiakov
bb88e283e3 Merge "Limit threads in pthread_leak#detach for low power devices." am: f8813d14aa
am: 31892ad6b2

Change-Id: Ibf1c2f0128ec109b3ff6de28bbdf0afa10f5d029
2019-05-20 21:48:33 -07:00
Treehugger Robot
f8813d14aa Merge "Limit threads in pthread_leak#detach for low power devices." 2019-05-21 02:15:30 +00:00
Christopher Ferris
035988ffb4 Temporarily disable unwind through signal test.
On cf_x86_phone-userdebug, both of the unwind through signal
tests fail. This has been failing forever, but seems to have suddenly
become an issue, so disable while I try to figure out why this is happening.

Bug: 132763120

Test: Ran on emulator and verified tests are skipped.
Change-Id: Iafc227d972a7783e94c701d73078c9570cea288e
Merged-In: Iafc227d972a7783e94c701d73078c9570cea288e
(cherry picked from commit d424fafbce)
(cherry picked from commit fe0fbcff7f)
2019-05-20 12:33:09 -07:00
Christopher Ferris
e732449c7c Temporarily disable unwind through signal test.
am: fe0fbcff7f

Change-Id: I888bdb87deacf136d64d63c44448fc54fdf2cfa6
2019-05-17 11:57:19 -07:00
Peter Collingbourne
21abeb2d54 Merge "Add bootstrap directory to bootstrap linker's search path." am: 8bb97d7781
am: 64db1aec2b

Change-Id: I0cb0d4a79dfeef0cdf82b87e44292dee090a2791
2019-05-17 00:23:31 -07:00
Peter Collingbourne
8bb97d7781 Merge "Add bootstrap directory to bootstrap linker's search path." 2019-05-17 02:26:29 +00:00
Peter Collingbourne
ea11be0cc8 Add bootstrap directory to bootstrap linker's search path.
A proposed set of changes:
https://android-review.googlesource.com/q/topic:"no-dup-hwasans"

will cause the HWASAN runtime to be moved from /system/lib64 to
/system/lib64/bootstrap. This causes a problem in the case where libc is built
with HWASAN but init is not built with HWASAN. In this case, libc.so will have
a DT_NEEDED dependency on the HWASAN runtime but init will not. Currently,
init and other bootstrap executables arrange to load bootstrap libraries by
setting rpath, but rpath only has an effect on libraries directly depended
on by the main executable, not libraries indirectly depended on by it. This
means that the loading of the HWASAN runtime will fail.

Instead of relying on rpath to find the bootstrap libraries, modify the
bootstrap linker so that it searches the bootstrap library directory after
searching the rpath.

Change-Id: I297be32e04ecd316ee12b8e694588e1249e2bb89
2019-05-16 16:10:41 -07:00
Christopher Ferris
fe0fbcff7f Temporarily disable unwind through signal test.
On cf_x86_phone-userdebug, both of the unwind through signal
tests fail. This has been failing forever, but seems to have suddenly
become an issue, so disable while I try to figure out why this is happening.

Bug: 132763120

Test: Ran on emulator and verified tests are skipped.
Change-Id: Iafc227d972a7783e94c701d73078c9570cea288e
Merged-In: Iafc227d972a7783e94c701d73078c9570cea288e
(cherry picked from commit d424fafbce)
2019-05-16 14:25:57 -07:00
Tom Cherry
c57c5bdb7f pwd/grp: fix pwd _r reentrancy, new tests, clean up
getpwnam_r() and getpwuid_r() clobber the storage used by getpwnam()
and getpwuid().  This isn't likely to be a big issue, but since we do
this right for the group functions, fix this as well as add a test.
Both use more space in buf than is actually required, but well below
their sysconf() suggested values, so we accept that to keep the code
concise.

Add tests for dealing with unaligned input buffers, particularly for
getgrnam_r() and getgrgid_r(), as they require alignment but this
wasn't being tested.

Refactor common initialization code for both passwd and group state
structs.

Remove extraneous null pointer checks; the values they were testing
were offsets of a previous pointer, so guaranteed to never actually be
null.  If the underlying pointer is actually null, we're beyond repair
anyway, so accept that we'll crash.

Test: pwd/grp unit tests

Change-Id: I60c4d00e9ab3cf55daf8314c5029fd914025b696
2019-05-15 15:49:34 -07:00
Elliott Hughes
d4452aef52 Merge "bionic_tests_zipalign: don't explicitly specify no prefix/suffix." am: 235ccfd19b
am: 36f53ef0eb

Change-Id: I30e77313cc602c0537e29df2637f0baad80f6d77
2019-05-10 18:52:59 -07:00
Elliott Hughes
be6c641141 bionic_tests_zipalign: don't explicitly specify no prefix/suffix.
Bug: http://b/129068177
Test: treehugger
Change-Id: If061ba04a0b3396898b6150d8fb1a8c27abb03f8
2019-05-10 16:59:13 -07:00
Dmytro Chystiakov
a339233629 Limit threads in pthread_leak#detach for low power devices.
This patch decreases created threads to 90 (instead of 100)
on devices with 2 cores CPU. This test can fail with timeout
on such devices.

Bug: b/129924384
Test: Run CtsBionic module on 2 core device with command
	"run cts -m CtsBionicTestCases"

Change-Id: Ic770006a324748d7d6dfbe8d4fb301e21e494ff9
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-05-10 16:44:49 -07:00
George Burgess IV
18e111caf9 Merge "tests: use clang's -verify instead of FileCheck" am: af68f04e44
am: c67f59fd15

Change-Id: If74a631fca9b73a470ae178e41062f296885cd9a
2019-05-09 15:34:42 -07:00
George Burgess IV
af68f04e44 Merge "tests: use clang's -verify instead of FileCheck" 2019-05-09 20:29:27 +00:00
Elliott Hughes
091c7186db Merge "Add SEEK_DATA and SEEK_HOLE constants." am: 1a60589b97
am: fbb1a0b029

Change-Id: Ifa3f5d78bd2df70a5e24bd8dcfdb55e8b456a80f
2019-05-07 15:07:21 -07:00
Elliott Hughes
31c7309dc6 Add SEEK_DATA and SEEK_HOLE constants.
Without pulling in <linux/fs.h>, the UAPI source of these constants,
because it's full of pollution, in particular a macro called BLOCK_SIZE
that breaks a lot of stuff.

Test: treehugger
Change-Id: I7258ec57e91c67645c2b4d0ce44850d757c4bb12
2019-05-07 10:03:02 -07:00
Elliott Hughes
e7fa613ea9 Merge "Track libziparchive API change." am: 9433a0299e
am: fd03d4a762

Change-Id: I5a9a45503c949d13e5f99afe108e9405ffc6162d
2019-05-06 17:39:10 -07:00
Ryan Prichard
9602fc4ae1 Merge "Revert fwalk/sfp locking to fix concurrent reads" am: f61ca22248
am: ab399dfd4a

Change-Id: Iaa08fc3d6035d9ad7a15a80a7f74b3bfce5d9b04
2019-05-06 17:38:26 -07:00
Ryan Prichard
c8e263becf Revert fwalk/sfp locking to fix concurrent reads
The locking can fail in a couple of ways:

 - A concurrent fread from an unbuffered or line-buffered file flushes
   the output of other line-buffered files, and if _fwalk locks every
   file, then the fread blocks until other file reads have completed.

 - __sfp can initialize a file lock while _fwalk is locking/unlocking it.

For now, revert to the behavior Bionic had in previous releases. This
commit reverts the file locking parts of commit
468efc80da.

Bug: http://b/131251441
Bug: http://b/130189834
Test: bionic unit tests
Change-Id: I9e20b9cd8ccd14e7962f7308e174f08af72b56c6
(cherry picked from commit c485cdb024)
2019-05-06 16:46:30 -07:00
Elliott Hughes
9433a0299e Merge "Track libziparchive API change." 2019-05-06 23:45:16 +00:00
Ryan Prichard
f61ca22248 Merge "Revert fwalk/sfp locking to fix concurrent reads" 2019-05-06 23:38:49 +00:00
George Burgess IV
db48e0c822 tests: use clang's -verify instead of FileCheck
Clang uses this for its own diagnostic tests. The nice feature it adds
here is that it fails if clang emits a diagnostic that we don't expect
(and we get to drop a dependency on FileCheck).

This also tweaks and renames file-check-cxx to reflect its new job.

Bug: 131861088
Test: mma
Change-Id: I77f7ce77869edaa23e2401e622ad7007d2fee06c
2019-05-04 11:53:12 -07:00
Ryan Prichard
c485cdb024 Revert fwalk/sfp locking to fix concurrent reads
The locking can fail in a couple of ways:

 - A concurrent fread from an unbuffered or line-buffered file flushes
   the output of other line-buffered files, and if _fwalk locks every
   file, then the fread blocks until other file reads have completed.

 - __sfp can initialize a file lock while _fwalk is locking/unlocking it.

For now, revert to the behavior Bionic had in previous releases. This
commit reverts the file locking parts of commit
468efc80da.

Bug: http://b/131251441
Bug: http://b/130189834
Test: bionic unit tests
Change-Id: I9e20b9cd8ccd14e7962f7308e174f08af72b56c6
2019-05-04 00:28:00 -07:00
Elliott Hughes
b51bb50471 Track libziparchive API change.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ieccd528a34b66de59fad78586dead6b1df9cae98
2019-05-03 22:45:41 -07:00
Christopher Ferris
f96e450f23 Fix malloc_info missing large allocs.
am: 125d32cb46

Change-Id: Ide2680c0fa59c2b9805f12045047cf1e6ab9f7eb
2019-05-03 07:59:37 -07:00
Christopher Ferris
db9706afc3 Fix malloc_info missing large allocs.
Also change the names of some of the functions to make it very obvious
that the functions being called are in je code.

Write new test to make sure mallinfo and malloc_info match.

Bug: 131864803

Test: New unit tests pass (along with all other bionic unit tests).
Change-Id: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
Merged-In: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
(cherry picked from commit 125d32cb46)
2019-05-03 07:21:45 -07:00
Christopher Ferris
125d32cb46 Fix malloc_info missing large allocs.
Also change the names of some of the functions to make it very obvious
that the functions being called are in je code.

Write new test to make sure mallinfo and malloc_info match.

Bug: 131864803

Test: New unit tests pass (along with all other bionic unit tests).
Change-Id: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
2019-05-03 14:15:12 +00:00
Elliott Hughes
cb28280bf1 Merge "Fix running tests/benchmarks on the host." am: dfa3231fae
am: 766c77f88e

Change-Id: I3672f2695ab95cb36b8c63228b2cf2dee0fc7eb2
2019-04-27 09:35:17 -07:00
Elliott Hughes
dfa3231fae Merge "Fix running tests/benchmarks on the host." 2019-04-27 16:15:21 +00:00
Elliott Hughes
4da99ffe5e Fix running tests/benchmarks on the host.
This was broken by all the mainline modules stuff. It's quite a bit
hairier to set up now, given that we don't have an apexd on the host.
An alternative might be to actually set up a fake /apex that points to
the bootstrap directories?

Test: ./benchmarks/run-on-host.sh 64
Test: ./tests/run-on-host.sh 64
Change-Id: If2c277ba492c7c443cdf51526ea42f56568e2ea6
2019-04-26 17:45:17 -07:00
Elliott Hughes
9082f4fd73 Merge "threads.h: Add C11 thread support." am: 8c3140a612
am: 3716c5320d

Change-Id: Ia843e59dbfa88d30a6f885bafdbb251323748c08
2019-04-24 14:01:38 -07:00
Elliott Hughes
8c3140a612 Merge "threads.h: Add C11 thread support." 2019-04-24 20:33:08 +00:00
Elliott Hughes
4206711352 threads.h: Add C11 thread support.
FreeBSD, glibc, and musl have all implemented C11 threads at this
point. POSIX is looking at how to align with it. Probably time to jump
on the bandwagon ourselves...

Implemented in the same style as <termios.h> so we can provide this
functionality even on older API levels. This does mean that this is
strictly more expensive than calling pthread functions directly.

Although this isn't in POSIX yet, assume that it's going to be basically
the same as C11 and add the header test anyway. We should revisit this
when POSIX actually adds <threads.h>.

Test: new tests
Change-Id: I8602d67ce71ca7f8ed1529daa0a8ea1feb083dd6
2019-04-24 09:12:29 -07:00
Ryan Prichard
53080db75a Merge "PIMutexUnlock: load owner_tid in non-common case" into qt-dev 2019-04-23 20:55:52 +00:00
Torne (Richard Coles)
ebfebd057a Only write main library's RELRO by default.
ANDROID_DLEXT_WRITE_RELRO was inadvertently writing out the RELRO
section of all libraries loaded during a given dlopen() call instead of
only the main library; since the other libraries are loaded at
unpredictable addresses this additional data is rarely useful.

Fix this to only happen when the
ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE flag is being used.

Bug: 128623590
Test: DlExtRelroSharingTest.CheckRelroSizes
Change-Id: I05e8651d06ce2de77b8c85fe2b6238f9c09691ad
(cherry picked from commit 5d10374947)
2019-04-23 12:21:56 -04:00
Ryan Prichard
ea722a0779 PIMutexUnlock: load owner_tid in non-common case
For a recursive or errorcheck PI mutex, the old_owner variable wasn't
being initialized. As a result, unlocking a doubly-locked recursive
mutex owned by another thread decremented the mutex counter. Instead, the
unlock call should fail with EPERM.

Bug: http://b/130841532
Test: bionic-unit-tests
Test: bionic-unit-tests-glibc --gtest_filter='pthread.pthread_mutex_lock*'
Change-Id: I37adb094cb2ce8d51df7b4f48e8d6bc144436418
(cherry picked from commit 4b6c0f5dce)
2019-04-23 00:19:30 -07:00
Torne (Richard Coles)
f0fe5b1bc1 Merge "Only write main library's RELRO by default." am: 401e2efa39
am: 33e88b0caa

Change-Id: I86510268396a09d13ca7b6359cc878670269e665
2019-04-22 17:12:16 -07:00
Treehugger Robot
401e2efa39 Merge "Only write main library's RELRO by default." 2019-04-22 23:26:36 +00:00
Ryan Prichard
2cedfb5291 Merge "PIMutexUnlock: load owner_tid in non-common case" am: b250766282
am: 3a186fa215

Change-Id: I08e060df1dd200142a2cf54f458349f04ffa2da4
2019-04-22 14:27:15 -07:00
Ryan Prichard
4b6c0f5dce PIMutexUnlock: load owner_tid in non-common case
For a recursive or errorcheck PI mutex, the old_owner variable wasn't
being initialized. As a result, unlocking a doubly-locked recursive
mutex owned by another thread decremented the mutex counter. Instead, the
unlock call should fail with EPERM.

Bug: http://b/130841532
Test: bionic-unit-tests
Test: bionic-unit-tests-glibc --gtest_filter='pthread.pthread_mutex_lock*'
Change-Id: I37adb094cb2ce8d51df7b4f48e8d6bc144436418
2019-04-19 17:16:16 -07:00
Torne (Richard Coles)
5d10374947 Only write main library's RELRO by default.
ANDROID_DLEXT_WRITE_RELRO was inadvertently writing out the RELRO
section of all libraries loaded during a given dlopen() call instead of
only the main library; since the other libraries are loaded at
unpredictable addresses this additional data is rarely useful.

Fix this to only happen when the
ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE flag is being used.

Bug: 128623590
Test: DlExtRelroSharingTest.CheckRelroSizes
Change-Id: I05e8651d06ce2de77b8c85fe2b6238f9c09691ad
2019-04-11 13:57:31 -04:00
Treehugger Robot
1701d887ac Merge "Move platform-private symbols out of libdl.so" 2019-04-05 16:45:49 +00:00
Ryan Prichard
3d7ebcdc72 Merge changes I59a8bc4a,Ic437d352 am: 93ea856949
am: 7287d1410f

Change-Id: I2629ec7e26b357ca778a9eb7bf00cf6778f60549
2019-04-04 18:10:17 -07:00
Ryan Prichard
3f05d3e971 Fix dlsym and dladdr for TLS symbols
* dlsym: call __tls_get_addr for TLS symbols

 * dladdr: skip TLS symbols

Bug: b/123772574
Test: bionic unit tests
Change-Id: I59a8bc4a7d455e1018b0d577b027b6417c8487cd
(cherry picked from commit e4d620bc80)
2019-04-04 16:46:59 -07:00
Ryan Prichard
93ea856949 Merge changes I59a8bc4a,Ic437d352
* changes:
  Fix dlsym and dladdr for TLS symbols
  Fix BionicAllocator comment
2019-04-04 20:38:47 +00:00
Dmytro Chystiakov
a9c347ccc2 Merge "Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations" am: 02accd0ff4
am: c011e04df6

Change-Id: Iab81349b19e8df469314a5c6e5ec538105436ec0
2019-04-04 08:56:53 -07:00
Treehugger Robot
02accd0ff4 Merge "Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations" 2019-04-04 14:59:21 +00:00
Ryan Prichard
e4d620bc80 Fix dlsym and dladdr for TLS symbols
* dlsym: call __tls_get_addr for TLS symbols

 * dladdr: skip TLS symbols

Bug: b/123772574
Test: bionic unit tests
Change-Id: I59a8bc4a7d455e1018b0d577b027b6417c8487cd
2019-04-03 18:19:50 -07:00
Torne (Richard Coles)
07603294cd Merge "Fix DLEXT_WRITE_RELRO when loading multiple libs." am: 865866ee2b am: c950489599
am: ce62c05753

Change-Id: I234ee6e837fe2609918cee82121aa3994afbd4d8
2019-04-03 09:12:36 -07:00
Treehugger Robot
865866ee2b Merge "Fix DLEXT_WRITE_RELRO when loading multiple libs." 2019-04-03 15:19:57 +00:00
Pirama Arumuga Nainar
74ce129f90 Merge "Move bionic-unit-tests-static to libclang_rt.builtins" am: 96c21e43b4 am: b993b94d41
am: 55615c7b2c

Change-Id: I40b8dc97589c0a48fed037d3a35be6e25ef1b48a
2019-04-03 08:19:53 -07:00
Pirama Arumuga Nainar
0d16a31664 Move bionic-unit-tests-static to libclang_rt.builtins
Bug: http://b/129728267
Bug: http://b/117167374

This test is now built with XOM (because libm now uses XOM) but it
should also use libclang_rt.builtins since libgcc is not built with XOM.

Test: bionic-unit-tests-static passes (but used to segfault with XOM
exceptions without this change).

Change-Id: I0b1dfe52e48db5f5e9386c7722ecd91e155be56f
2019-04-02 22:45:29 -07:00
Torne (Richard Coles)
fa9f7f28d4 Fix DLEXT_WRITE_RELRO when loading multiple libs.
ANDROID_DLEXT_WRITE_RELRO was causing the GNU RELRO sections of
libraries to become corrupted if more than one library was being loaded
at once (i.e. if the root library has DT_NEEDED entries for libraries
that weren't already loaded). The file offset was not being correctly
propagated between calls, so after writing out the (correct) RELRO data
to the file, it was mapping the data at file offset 0 for all libraries,
which corrupted the data for all but one of the libraries.

Fix this by passing file_offset as a pointer the same way that
phdr_table_map_gnu_relro does.

Bug: 128623590
Test: tbd
Change-Id: I196cd336bd5a67454e89fd85487356b1c7856871
2019-04-02 18:06:12 -04:00
Christopher Ferris
667457767e Merge "Create a lib that uses scudo instead of jemalloc." am: d486e024c6 am: b525ee4a11
am: f3edfb5773

Change-Id: Ie30808227d135bd9b60f0ae8c6c408523e7c6ea7
2019-04-01 19:13:34 -07:00
Christopher Ferris
fc26d71af1 Create a lib that uses scudo instead of jemalloc.
The media processes already use scudo as their allocator. However, it
doesn't really correctly replace the normal allocation functions, so create
a set of wrappers that allow us to use scudo closer to how jemalloc is used.

This is only a temporary change, and should be removed for the next
release of Android. In that version, we will be using standalone
scudo which won't require this wrapper code.

Bug: 123689570

Test: Ran new bionic unit tests. There are failures, but only with
Test: extensions that scudo does not support.

Change-Id: I0516c23d654a9b6c69b157c5501245d2e0b3d264
2019-04-01 13:02:49 -07:00
dimitry
8868d9e900 Move platform-private symbols out of libdl.so
Symbols not intended to be accessible from apps are moved to libdl_android.so

Test: bionic-unit-tests
Bug: http://b/129387775
Change-Id: Ib8ba6147a20cf56550c9a008f66570a2d419565a
(cherry picked from commit 2d6be9a751)
2019-04-01 13:16:33 +02:00
Yi Kong
d116f8d23b Merge "Modernise code to use override specifier" am: 4699cf6174 am: 2e3a19d5b4
am: d3a825fe61

Change-Id: Ia5e05fd2fdf4d6a003fe6960bca1bd41487ecc05
2019-03-29 19:42:35 -07:00
Yi Kong
358603a409 Modernise code to use override specifier
Generated by clang-tidy.

Test: m checkbuild
Change-Id: I8e23da6b8af31b291be2eefe9937ca222ea8a8c3
2019-03-29 14:27:27 -07:00
Dmytro Chystiakov
e712cd185f Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations
64bit libraries should be located in /system/lib64 directory
instead of /system/lib for platforms with emulated arhitecture.

This patch updated ALTERNATE_PATH_TO_SYSTEM_LIB for 64bit values

Test: run cts -m CtsBionicTestCases -t dlfcn.dladdr_libc

Change-Id: I29d6d36d15d7e61818c7ed1cfd0786745d9ae6a2
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-03-29 13:49:12 -07:00
Dimitry Ivanov
3158355507 Merge "Move platform-private symbols out of libdl.so" 2019-03-28 09:05:52 +00:00
Elliott Hughes
d50f8bc35a Merge "tests: test both upper- and lower-case with strptime %P/%p." am: 2e824e3150 am: 9d1ae96262
am: 6f46e9eeb7

Change-Id: I579faf2ab1a465ce565a6b3631a0e54d8c6c0416
2019-03-27 14:15:26 -07:00
Treehugger Robot
2e824e3150 Merge "tests: test both upper- and lower-case with strptime %P/%p." 2019-03-27 20:54:59 +00:00
Elliott Hughes
1bff6265d1 Merge "Convert new tests to GTEST_SKIP." am: e7ee0731c3 am: 94cd62ccd1
am: cb78141d64

Change-Id: Ibf809532aa5cf8389d09a37bd145991732fc9a49
2019-03-27 13:22:51 -07:00
Treehugger Robot
e7ee0731c3 Merge "Convert new tests to GTEST_SKIP." 2019-03-27 20:04:49 +00:00
Elliott Hughes
cb70a9a700 Merge "strptime: support everything that strftime supports." am: ff923681be am: 06acbcfb64
am: d8dfb05b6b

Change-Id: I58582ccf8c82b89d27ffba0d3ab460f4e09264f2
2019-03-27 09:09:52 -07:00
Elliott Hughes
1167882a87 tests: test both upper- and lower-case with strptime %P/%p.
Test: ran tests
Change-Id: I7275808f2f0ae4f02d057542a13350895022910c
2019-03-27 08:56:49 -07:00
Elliott Hughes
109072038a Convert new tests to GTEST_SKIP.
These went in while we were waiting for the infrastructure to catch up.

Test: treehugger
Change-Id: I1179d1aba8f1369d320f82705958b36c6930babf
2019-03-27 08:51:02 -07:00
Elliott Hughes
7d3ed1435f Merge "bionic tests: use GTEST_SKIP." am: e08288465e am: 64bc28143f
am: 619d7bd404

Change-Id: I69aba8b645516a51dfa66394da67ff854f6e3016
2019-03-26 19:26:10 -07:00
Elliott Hughes
a1fb15bb67 strptime: support everything that strftime supports.
Our strptime was missing `%F`, `%G`, `%g`, `%P`, `%u`, `%V`, and
`%v`. Most of these are already supported upstream (and I've just pulled
their current implementation), but some aren't. We're horribly out of
sync anyway, so I'll upstream the missing pieces and then try to get us
back in sync later.

Test: new tests, but originally found by toybox trying to use %F
Change-Id: Ib1a10801a7a3b9c9189440c3b300109bde535fd9
2019-03-26 19:07:40 -07:00
Elliott Hughes
e08288465e Merge "bionic tests: use GTEST_SKIP." 2019-03-27 02:05:57 +00:00
Elliott Hughes
36fa2647af Merge "Fix running the tests on the host again." am: b0c33ecb99 am: 1f63174243
am: b462788ee1

Change-Id: I87615ed7b66bc3efa0da2ac4b697b31754a646f4
2019-03-26 17:50:24 -07:00
Elliott Hughes
8ceb95c506 Fix running the tests on the host again.
Bug: N/A
Test: ran the tests on the host under glibc
Change-Id: Id05a896bdd11b231304ed1a08ef24e1a661ee20d
2019-03-26 14:47:08 -07:00
Nick Kralevich
d4b46b3896 Merge "Make powerof2 macro ubsan safe" am: 1b6517b601 am: cdfe9d7d96
am: 91479bb201

Change-Id: I7f3513a4c009879a909e0eaeecc06b3990e634d7
2019-03-25 21:05:45 -07:00
Nick Kralevich
c50b6a2b89 Make powerof2 macro ubsan safe
Subtracting one from the smallest value expressable by the provided
variable could cause an underflow operation. In particular, this is
problematic when code similar to:

  uint64_t foo = 0;
  if (powerof2(foo)) {
    ...;
  }

is run with integer sanitization enabled. The macro would subtract one
from zero, underflowing and triggering the sanitizer.

Make the powerof2() macro ubsan safe, by explicitly handling underflows.

Note: This change DOES NOT make powerof2() accurate. We continue to
falsely return "true" for 0 and negative numbers (see attached tests).

Found while investigating Bug: 122975762
Test: see added testcase
Test: atest ziparchive-tests

Change-Id: I5408ce5c18868d797bcae8f115ddb7c4c1ced81e
2019-03-25 13:51:33 -07:00
Evgenii Stepanov
a27b0180a9 Merge "Disable malloc_info test under HWASan." am: e187d92062 am: c1437e8bf0
am: 18c641bbb9

Change-Id: I0902f47bb0e22abf52a341b7d138909bc86c8b7c
2019-03-22 16:03:48 -07:00
Evgenii Stepanov
8de6b46ad8 Disable malloc_info test under HWASan.
HWASan does not implement malloc_info.

Test: bionic-unit-tests with SANITIZE_TARGET=hwaddress
Change-Id: I61d50d9110fbca1784ed39950ed6c5540ca0c9a7
2019-03-22 13:23:18 -07:00
dimitry
2d6be9a751 Move platform-private symbols out of libdl.so
Symbols not intended to be accessible from apps are moved to libdl_android.so

Test: bionic-unit-tests
Change-Id: Ib8ba6147a20cf56550c9a008f66570a2d419565a
2019-03-20 12:16:57 +01:00
Evgenii Stepanov
02e63858d4 Merge "Annotate vfork for hwasan." am: 8b8e7d0461 am: 48c5b26a9a
am: a5446bcd76

Change-Id: I8c813020457a92db956c05eb1812cb9e9df2cd78
2019-03-19 21:39:18 -07:00
Evgenii Stepanov
505168e530 Annotate vfork for hwasan.
Call a hwasan hook in the parent return path for vfork() to let hwasan
update its shadow. See https://github.com/google/sanitizers/issues/925
for more details.

Bug: 112438058
Test: bionic-unit-tests
Change-Id: I9a06800962913e822bd66e072012d0a2c5be453d
2019-03-19 23:36:44 +00:00
Peter Collingbourne
425ea70447 Merge "Add a platform API for setting an allocation limit." am: 9d69d4ccae am: ef4af2fb8c
am: a51cc27724

Change-Id: I9e98264aa3000c381888a61dd2a0e413bb481893
2019-03-15 15:56:00 -07:00
Peter Collingbourne
9d69d4ccae Merge "Add a platform API for setting an allocation limit." 2019-03-15 21:51:46 +00:00
Elliott Hughes
7ce3788d19 Merge "Remove __INTRODUCED_IN_FUTURE." am: ea6c19a44b am: ff72341e77
am: 5d8cab8381

Change-Id: I11c4b80c535396d66e6f5f77bc853b28c917dbff
2019-03-15 14:20:25 -07:00
Elliott Hughes
ea6c19a44b Merge "Remove __INTRODUCED_IN_FUTURE." 2019-03-15 19:54:57 +00:00
Christopher Ferris
1fc5ccfe76 Add a platform API for setting an allocation limit.
Introduce an M_SET_ALLOCATION_LIMIT enumerator for android_mallopt(),
which can be used to set an upper bound on the total size of all
allocations made using the memory allocation APIs.

This is useful for programs such as audioextractor and mediaserver
which need to set such a limit as a security mitigation. Currently
these programs are using setrlimit(RLIMIT_AS) which isn't exactly
what these programs want to control. RLIMIT_AS is also problematic
under sanitizers which allocate large amounts of address space as
shadow memory, and is especially problematic under shadow call stack,
which requires 16MB of address space per thread.

Add new unit tests for bionic.

Add new unit tests for malloc debug that verify that when the limit
is enabled, malloc debug still functions for nearly every allocation
function.

Bug: 118642754
Test: Ran bionic-unit-tests/bionic-unit-tests-static.
Test: Ran malloc debug tests and perfetto integration tests.
Change-Id: I735403c4d2c87f00fb2cdef81d00af0af446b2bb
2019-03-15 10:54:55 -07:00
Yi Kong
8a83ba8fe5 Merge "Reduce reserved size for DlExtTest.ReservedRecursiveTooSmall test" am: 4c95542fdf am: 3251497a3f
am: b4c2a40c95

Change-Id: I442c904a1f5919e0a2962e31df8010234b653605
2019-03-14 20:09:42 -07:00
Yi Kong
1e7a150339 Reduce reserved size for DlExtTest.ReservedRecursiveTooSmall test
When built with clang-r353983, the ReservedRecursiveTooSmall test fail
due to the reserved memory is now large enough for android_dlopen_ext.
Reduce the reserved memory size to agree with ReservedTooSmall test.

Test: bionic-unit-tests
Bug: 126457671
Change-Id: I3e311a3f35b0de5d028fa1b9b3681d5ec32faee8
2019-03-14 16:25:45 -07:00
Elliott Hughes
5270017ab3 Remove __INTRODUCED_IN_FUTURE.
This hasn't been particularly useful, we haven't used it consistently,
and it has caused trouble.

Test: builds
Change-Id: Ic5b5b5124af98aa8301e602fd75b0eb72a5fc7f6
2019-03-14 13:34:21 -07:00
Elliott Hughes
bcaa454d32 bionic tests: use GTEST_SKIP.
Also be a bit more to the point in our messages, focusing on "why" not
"what".

Test: ran tests
Change-Id: I297806c7a102bd52602dcd2fcf7a2cd34aba3a11
2019-03-12 10:26:39 -07:00
Peter Collingbourne
72cf0b4311 Merge "linker: Handle libraries with disjoint mappings correctly." am: 432db6cfaf am: d7fc90e601
am: b3c32cd7b6

Change-Id: Icd7a4c71d2209ae822d2b7511ea159350be48b0a
2019-03-09 06:20:39 -08:00
Treehugger Robot
432db6cfaf Merge "linker: Handle libraries with disjoint mappings correctly." 2019-03-09 05:40:03 +00:00
Peter Collingbourne
b39cb3c31d linker: Handle libraries with disjoint mappings correctly.
It's possible and sometimes beneficial for a library to have disjoint mappings
and for other libraries to be mapped into the gap between the mappings using
ANDROID_DLEXT_RESERVED_ADDRESS. See for example the proposal for partitioning
in lld [1].

Because the find_containing_library and do_dl_unwind_find_exidx functions use
a simple bounds check to figure out whether a pointer belongs to a library
they will, given a pointer into a library mapped into the gap of a library
with disjoint mappings, return a pointer to the soinfo for the outer library
instead of the inner one, because the outer library will appear before the
inner one in the solist.

From a user perspective this means that we won't be able to unwind the inner
library's frames on 32-bit ARM with libgcc, dladdr() will return information
for the outer library given a pointer to the inner one and dlopen() et al will
use the linker namespace of the outer library when called from the inner one
(although they will usually be the same).

To make this work correctly, make it so that once find_containing_library
sees a match for the bounds check, it examines the library's PT_LOADs to
make sure that there is a mapping for the given address. This is similar
to how libgcc and libunwind_llvm already handle finding the PT_GNU_EH_FRAME
on non-ARM32 platforms [2,3]. do_dl_unwind_find_exidx is reimplemented in
terms of find_containing_library.

[1] http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html
[2] e739ac0e25/libunwind/src/AddressSpace.hpp (L523)
[3] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.9/libgcc/unwind-dw2-fde-dip.c#294

Test: /data/nativetest{,64}/bionic-unit-tests/bionic-unit-tests on walleye-userdebug
Change-Id: I368fe6ad3c470b3dff80f7d9b04253566d63a7d2
2019-03-08 18:34:34 -08:00
Christopher Ferris
6c619a0da3 Refactor the malloc_info code.
malloc_info needs to be per native allocator, but the code treated it
like a global function that doesn't depend on the native memory allocator.

Update malloc debug to dump the actual pointers that it has been tracking.

Test: bionic-unit-tests pass.
Test: malloc debug tests pass.
Test: malloc hook tests pass.
Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e
Merged-In: I3b0d4d748489dd84c16d16933479dc8b8d79013e
(cherry picked from commit a3656a98b1)
2019-03-07 08:39:55 -08:00
Christopher Ferris
f6ea33916e Merge "Refactor the malloc_info code." 2019-03-07 16:28:22 +00:00
vichang
5f9634b004 Merge "bionic-unit-tests should depend on libandroidicu instead" am: 4e167f35d6 am: df9e4e5ae2
am: bbe4a4dd48

Change-Id: I4fa8b79c14b4a7e4faa9dc28bd990b71805bc577
2019-03-06 15:46:26 -08:00
vichang
4e167f35d6 Merge "bionic-unit-tests should depend on libandroidicu instead" 2019-03-06 23:05:24 +00:00
Victor Chang
ddcf488ef6 bionic-unit-tests should depend on libandroidicu instead
bionic has been moved to use libandroidicu instead of libicuuc.
This CL updates the unit test

Bug: 120659668
Test: m bionic-unit-tests && adb push out/target/product/walleye/data/nativetest/* /data/nativetest && adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Change-Id: I59a0589d18bfd6753215dc07874f3c472bd64cca
2019-03-06 18:29:55 +00:00
Christopher Ferris
a3656a98b1 Refactor the malloc_info code.
malloc_info needs to be per native allocator, but the code treated it
like a global function that doesn't depend on the native memory allocator.

Update malloc debug to dump the actual pointers that it has been tracking.

Test: bionic-unit-tests pass.
Test: malloc debug tests pass.
Test: malloc hook tests pass.
Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e
2019-03-05 12:52:55 -08:00
Christopher Ferris
c32e6747b7 Merge "Make aligned_alloc match the standard." am: b8ef55a4f8 am: 4917f6f575
am: 5cbbc36698

Change-Id: I396705b8822e1fca827e214d5a622f0c2651c979
2019-03-02 11:31:38 -08:00
Christopher Ferris
a22f5d5175 Make aligned_alloc match the standard.
Jemalloc does not verify that the size parameter is a multiple of
alignment. Fix this since it only went into P.

Fix the unit tests, and fix malloc debug/malloc hooks to handle this
new restrictive behavior.

Bug: 126944692

Test: Ran bionic unit tests.
Test: Ran bionic unit tests with malloc hooks enabled (no new tests fail).
Test: Ran bionic unit tests with malloc debug enabled (no new tests fail).
Test: Ran malloc debug unit tests.
Change-Id: I4d50785928815679c781ca729f998454d76b9192
2019-03-01 23:56:23 -08:00
Torne (Richard Coles)
d4184e7349 Merge "linker: allow using reserved space for multiple libraries." am: 7cdbd0d477 am: ac0e655b40
am: db850fa4b3

Change-Id: If60a4bccb7b8ca3cc9a9c41e818ab18cc6c8800e
2019-02-25 08:50:17 -08:00
Treehugger Robot
7cdbd0d477 Merge "linker: allow using reserved space for multiple libraries." 2019-02-21 16:06:17 +00:00
Torne (Richard Coles)
efbe9a5eef linker: allow using reserved space for multiple libraries.
Introduce a new flag ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE which
instructs the linker to use the reserved address space to load all of
the newly-loaded libraries required by a dlopen() call instead of only
the main library. They will be loaded consecutively into that region if
they fit. The RELRO sections of all the loaded libraries will also be
considered for reading/writing shared RELRO data.

This will allow the WebView implementation to potentially consist of
more than one .so file while still benefiting from the RELRO sharing
optimisation, which would otherwise only apply to the "root" .so file.

Test: bionic-unit-tests (existing and newly added)
Bug: 110790153
Change-Id: I61da775c29fd5017d9a1e2b6b3757c3d20a355b3
2019-02-20 17:29:36 -05:00
Tom Cherry
35e3d2ba85 Merge "Waive AID Range check for devices through Q" am: c46cc7d83d am: f75bca93cc
am: 0559ddb5ce

Change-Id: I8e5fd639daaf432368dcf89d179d50976bce17fb
2019-02-20 03:03:51 -08:00
Tom Cherry
9da8ff1270 Waive AID Range check for devices through Q
We still don't have a good way to create vendor AIDs in the system or
other non-vendor partitions, therefore we keep this check disabled.

Bug: 73062966
Test: treehugger
Change-Id: I7aed425899d6ec11a22702ccec82476eacdbc790
2019-02-19 13:24:59 -08:00
Sandeep Patil
63619b5816 Merge "bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile" am: cf6cec8489 am: 761b215dc7
am: bee2dda45c

Change-Id: I383c9e7e91755f387a19ecb1329e3cb391654a62
2019-02-15 15:25:17 -08:00
Treehugger Robot
cf6cec8489 Merge "bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile" 2019-02-15 23:03:00 +00:00
Christopher Ferris
5b2d135288 Merge "Refactor malloc common into distinct pieces." am: c2136b51aa am: 578f95aeb3
am: 13b4fcbb78

Change-Id: I0ca4a7293fc0fe24caf749960e78b797d3bf72b5
2019-02-13 11:20:47 -08:00
Christopher Ferris
c2136b51aa Merge "Refactor malloc common into distinct pieces." 2019-02-13 18:38:22 +00:00
Ryan Prichard
4df5b75a78 Merge "Only test tprel_missing_weak in dynamic binaries" am: 40f18976db am: 61d56a7a75
am: b233479974

Change-Id: Idf407c79b6caa6b6e68f217aa2c751b73b54c7fb
2019-02-12 16:47:34 -08:00
Christopher Ferris
e4cdbc4754 Refactor malloc common into distinct pieces.
The pieces:
- The malloc common shared by static and dynamic code (malloc_common.cpp).
- The code for shared libraries that includes any dlopen'ing
  (malloc_common_dynamic.cpp).
- The implementation of perfetto's heapprofd (malloc_heapprofd.cpp).

This makes it easier to see what's going on in the many different areas.
It should also make it easier to add the allocation capping option.

Other related changes:
- Update the unit tests for android_mallopt. All of the current options
  don't work on static binaries, so make sure that is reflected in the test.
- A few names changes to make sure that all code is consistent.

Test: Ran tests (malloc hooks/malloc debug/perfetto/bionic unit tests).
Change-Id: I0893bfbc0f83d82506fac5d1f37cf92fbdef6f59
2019-02-12 14:19:07 -08:00
Ryan Prichard
7fda2c9495 Only test tprel_missing_weak in dynamic binaries
Rename a test to be less confusing when this file tests unresolved weaks
with both TPREL and TLSDESC relocations.

Bug: http://b/123635978
Test: bionic unit tests
Change-Id: Id17d76a41159d134d16e84a699cc284662eb99bb
2019-02-11 18:37:17 -08:00
Sandeep Patil
7d2aea09dd bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile
Bug: 123532375
Test: Builds

Change-Id: I8e782d9050b4d6a0726e8c880d4064df99c763e5
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-02-10 17:27:39 -08:00
Christopher Ferris
c40c32935b Merge "Fix flakiness of mallinfo test." am: 2eb1fc9df0 am: ecd1c9e235
am: 078f208d3f

Change-Id: Iddd42fd6fef7ba60ba53b643142508ae5d74ee77
2019-02-07 16:58:33 -08:00
Christopher Ferris
4e56228637 Fix flakiness of mallinfo test.
The test was really only supposed to verify that mallinfo eventually
increase after allocations of certain sizes. Sometimes the mallinfo
returned decreases due to some compaction event, so don't fail in that
case.

Bug: 124060188

Test: Ran the test 2000 times (32 bit and 64 bit). It would fail within about
Test: 200 test iterations before.
Change-Id: Ie019107be163dcf275cedf4d1bc5759278def483
2019-02-07 14:20:03 -08:00