Commit graph

32740 commits

Author SHA1 Message Date
Elliott Hughes
a1e3f2c502 Expose a function to reset the stack protector for the zygote.
This is already covered by the existing test by virtue of being used for
all threads.

Bug: http://b/168258494
Test: treehugger
Change-Id: I5c872fd7f30a4c79de1d70e7702f4b12d4e94cd3
2020-09-11 08:56:58 -07:00
Peter Collingbourne
bba9153c5c Merge "Implement a new mechanism to let Scudo access the TLS slot" 2020-09-10 23:02:03 +00:00
Peter Collingbourne
38d290a11d Implement a new mechanism to let Scudo access the TLS slot
An upcoming change to Scudo will change how we use the TLS slot
in tsd_shared.h, which will be a little easier to deal with if
we can remove the code path that calls pthread_getspecific and
pthread_setspecific. The only known user of this code path is Fuchsia.

We can't eliminate this code path by making Fuchsia use ELF TLS
because although Fuchsia supports ELF TLS, it is not supported within
libc itself. To address this, Roland McGrath on the Fuchsia team has
proposed that Scudo will optionally call a platform-provided function
to access a TLS slot reserved for Scudo. Android also has a reserved
TLS slot, but the code that accesses the TLS slot lives in Scudo.

We can eliminate some complexity and duplicated code by having Android
implement the same mechanism that was proposed for Fuchsia, which is
what this change does. A separate change to Scudo will make use of it.

Bug: 163630045
Change-Id: I4678105c9c47a23feb5a5e80a314416de4556d9c
2020-09-10 13:55:24 -07:00
Elliott Hughes
ba4b40602a Merge "NGREG != ELF_NGREG." am: a5a9992671
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1419433

Change-Id: I9447c49cd08bfac0f127229455529bffdfd23c56
2020-09-09 20:17:43 +00:00
Elliott Hughes
a5a9992671 Merge "NGREG != ELF_NGREG." 2020-09-09 19:54:46 +00:00
Elliott Hughes
8e5fc5b037 NGREG != ELF_NGREG.
Except they are the same on arm32/arm64, so we hadn't really noticed. x86
and x86-64 are quite different though, presumably by historical accident.

Fix the definitions and add some static asserts.

Bug: https://github.com/android/ndk/issues/1347
Test: treehugger
Change-Id: Ic27b172066cf3443749463b9b73c912d204f9516
2020-09-08 09:27:02 -07:00
Xin Li
86214f6d88 Merge "Skip RP1A.200720.011" into stage-aosp-master 2020-09-02 19:15:47 +00:00
Tom Cherry
4473d90316 Merge "Add benchmark for property mapping" am: 7e0816a0a4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1417669

Change-Id: I357733be71ebedf37dcf28d49f24c0dcdf149493
2020-09-02 19:05:58 +00:00
Xin Li
59cee9f405 Skip RP1A.200720.011
Bug: 167588565
Merged-In: I99d71533c73a721877bd43fa759912c7c5b60351
Change-Id: I55c193a9b35db7d2516296c79c33fa2837b3e54b
2020-09-02 12:01:10 -07:00
Xin Li
204da165b1 Mark RP1A.200720.001 as merged
Bug: 167588565
Merged-In: Ic00db40d010c75b2384796c19751226bec5519fd
Change-Id: If4e3cddf2e03fb529a2830a3988f97ce557222db
2020-09-02 11:44:47 -07:00
Tom Cherry
7e0816a0a4 Merge "Add benchmark for property mapping" 2020-09-02 18:25:16 +00:00
Tom Cherry
a5744e213f Add benchmark for property mapping
This benchmarks mapping property prefixes to property contexts with
two algorithms: the 'Legacy' method used before Android P and the
'Trie' used afterwards (the code in this directory).

It uses input mappings from both Oreo and the latest in AOSP ('S').
Note that there is nearly a 10x increase in the number of mappings in
S as there was in Oreo, which was predicted when the trie was
designed.

Results on cuttlefish:
-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
LegacyLookupOreo     683576 ns       673538 ns         1060
LegacyLookupS       5683109 ns      5596982 ns          124
TrieLookupOreo       299851 ns       295696 ns         2378
TrieLookupS          584831 ns       576801 ns         1204

The results show that the legacy look up uses 8.3x more CPU time to
handle the number of mappings added through S, whereas the Trie lookup
uses less than 2x more CPU time, showing that the trie scales better
with added mappings.

Test: run this benchmark
Change-Id: I35c3aa4429f049e327a891f9cbe1901d8855d7ba
2020-09-02 16:12:21 +00:00
Treehugger Robot
57af5a7c73 Merge "Incorporate upstream's strptime %Z/%z support." am: 159bb3f86b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1417572

Change-Id: Ic00db40d010c75b2384796c19751226bec5519fd
2020-09-02 15:49:39 +00:00
Treehugger Robot
159bb3f86b Merge "Incorporate upstream's strptime %Z/%z support." 2020-09-02 12:17:11 +00:00
Elliott Hughes
d065c0489e Incorporate upstream's strptime %Z/%z support.
I made toybox use strptime %Z recently (so that it can parse the default
POSIX date(1) output), forgetting that bionic's strptime(3) doesn't
support %Z. Neither does glibc, for that matter; the toybox change works
on glibc effectively by accident --- glibc just ignores the next word
when parsing %Z and assumes that the current time zone ($TZ) is
appropriate. Which it is for the only obvious use case of "round trip
date(1) output".

The related %z is potentially quite a bit more useful in general (parsing
any valid RFC822 time zone), though sadly not useful for the toybox case
that prompted.

Every time I touch this file I promise that I'll actually get us back in
sync with upstream, and every time I fail to get round to it. Maybe
2020 or 2021 will finally be the year...

Also add corresponding tests.

Bug: https://b/167455975
Test: treehugger
Change-Id: I13a7fb7e3ad01ae855750b9314d2eec661fe034f
2020-09-01 19:11:28 -07:00
Josh Gao
f5493e8ec9 Merge "Add fdtrack docs." am: 984b4e9ae1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1416649

Change-Id: I462a904a9851d1c6e9a699b49e42713141e697f7
2020-09-01 22:41:14 +00:00
Josh Gao
984b4e9ae1 Merge "Add fdtrack docs." 2020-09-01 21:51:31 +00:00
Josh Gao
12a0eb6c6d Add fdtrack docs.
Test: none
Change-Id: I035be350cfd40cdbff1e95332f96841001922454
2020-08-31 19:12:46 -07:00
Xin Li
7a265e76f2 Mark Android R (rvc-dev-plus-aosp-without-vendor@6692709) as merged
Bug: 166295507
Merged-In: I456220a914c602b5fc6b88dccf8dcfbcae0a3f8c
Change-Id: I19d39d36d7bcbf212b2b6c22f979231e1a349da5
2020-08-27 09:44:04 -07:00
Vy Nguyen
7aad6a87b2 Merge "Updated __libc_get_static_tls_bounds test to be more meaningful" am: f3c1b60d53
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1409507

Change-Id: I39c9fa3cae00612732692e84d6f6ff2a8885cccd
2020-08-27 04:59:55 +00:00
Vy Nguyen
f3c1b60d53 Merge "Updated __libc_get_static_tls_bounds test to be more meaningful" 2020-08-27 04:07:34 +00:00
Vy Nguyen
97ba12b972 Updated __libc_get_static_tls_bounds test to be more meaningful
Change-Id: I20b8716affd35f940f607d92f761736fba0a66fd
2020-08-26 21:34:28 -04:00
Treehugger Robot
3459e3fffa Merge "bionic_systrace: moving global static variables" am: 37e112f60a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1408030

Change-Id: I0468e27337caf48cbec68b6d275fb828b5351bed
2020-08-25 03:45:04 +00:00
Treehugger Robot
37e112f60a Merge "bionic_systrace: moving global static variables" 2020-08-25 02:52:56 +00:00
Bowgo Tsai
1e1c7845aa bionic_systrace: moving global static variables
Some global static variables are only used within a single function,
so moving them inside the function which requires them. This also
ensures those static variables of class types are initialized before
they are being used.

For example, this is needed for CachedProperty(), as some of the
member method, e.g., CachedProperty().Get(), might be invoked,
e.g., in __libc_preinit(), before the constructor is invoked.
This happens after we added property trace points in commit
Id2b93acb2ce02b308c0e4889f836159151af3b46.

For g_lock, we don't move them because it can be initialized by setting
its memory to 0. And it's used in two functions.
  https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/private/bionic_lock.h

Bug: 147275573
Test: atest CtsBionicTestCases
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s bionic sysprop
Change-Id: I99565ce2442d34f33830778915c737eed834f8b3
2020-08-25 02:26:30 +00:00
Josh Gao
2206289fe6 Merge "async_safe: don't call libc's socket." am: 1e0d28b9c2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1406411

Change-Id: I11b3694cf294406f7badbd08a8d758eb86351f74
2020-08-21 23:54:26 +00:00
Josh Gao
1e0d28b9c2 Merge "async_safe: don't call libc's socket." 2020-08-21 23:34:20 +00:00
Treehugger Robot
ece7a0fe80 Merge "Fix issues with .note.GNU-stack section directives." am: 3d59029a12
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1406329

Change-Id: I36b63b49f50131af0ce0b42e4fd20f27752aca79
2020-08-21 21:39:20 +00:00
Josh Gao
d37113311c async_safe: don't call libc's socket.
Like with close, socket is no longer a simple syscall, so we can get
recursive calls that deadlock.

Bug: http://b/165206592
Test: bionic-unit-tests on cuttlefish
Test: treehugger
Change-Id: I2ba77d733d1ebf08a91afd6ca179e7ae6ae3866e
2020-08-21 14:23:57 -07:00
Treehugger Robot
3d59029a12 Merge "Fix issues with .note.GNU-stack section directives." 2020-08-21 21:22:14 +00:00
Stephen Hines
c68ec152d1 Fix issues with .note.GNU-stack section directives.
bionic/libm/x86_64/s_log1p.S:809:2: error: changed section type for .note.GNU-stack, expected: 0x1
 .section .note.GNU-stack, ""
 ^

These assembly sources are missing @progbits to set the section flags
correctly. Without it, they end up denoting a different section type. By
adding the @progbits explicitly, we see the same section flags with
readelf.

[ 4] .note.GNU-stack   PROGBITS        0000000000000000 000593 000000 00      0   0  1

Bug: http://b/155835175
Test: m for aosp_x86_64
Change-Id: Ifff35d35f5f9ded5938e88677b18805809820e9f
2020-08-21 12:17:12 -07:00
Treehugger Robot
0b27445a7e Merge "Adding system property tracing" am: 08bcaac208
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1403568

Change-Id: Ia80359428c9faeada5a496e15156af775dac3bc2
2020-08-21 10:06:13 +00:00
Treehugger Robot
08bcaac208 Merge "Adding system property tracing" 2020-08-21 09:33:53 +00:00
Bowgo Tsai
d0ecf0b30d Adding system property tracing
Introducing a new systrace tag, TRACE_TAG_SYSPROP, for use with
system property.

For property set, the tracing is added in __system_property_set() instead of
__system_property_update() / __system_property_add() so we can record
control properties like ctl.*, sys.powerctl.*, etc.., which won't be
updated via the latter two functions.

Bug: 147275573
Test: atest CtsBionicTestCases
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s bionic
Test: adb shell perfetto -o /data/misc/perfetto-traces/test_trace -t 10s sysprop
Test: adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks \
      --benchmark_filter=BM_property --bionic_cpu=4, then compares the results
      of property benchmarks before and after the change, didn't see
      significant difference.

Change-Id: Id2b93acb2ce02b308c0e4889f836159151af3b46
Merged-In: Id2b93acb2ce02b308c0e4889f836159151af3b46
(cherry picked from commit 26970c3493)
2020-08-19 12:47:01 +08:00
Treehugger Robot
97cefc6ea9 Merge "Cast from const void * -> const char * when using memchr()." am: 3ec750e035
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1401905

Change-Id: I3013a0ebad8bd43418cadff37978b4e703dc860e
2020-08-18 15:51:04 +00:00
Treehugger Robot
3ec750e035 Merge "Cast from const void * -> const char * when using memchr()." 2020-08-18 15:34:36 +00:00
Stephen Hines
62165a1808 Cast from const void * -> const char * when using memchr().
bionic/tests/fortify_test.cpp:207:31: error: format specifies type 'char *' but the argument has type 'void *' [-Werror,-Wformat]
  ASSERT_FORTIFY(printf("%s", memchr(myfoo.a, 'a', asize)));
                         ~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Bug: http://b/155835175
Test: atest for bionic
Change-Id: I0fa4e63deadffb7391e66ab834ff11e4f1d6dba6
2020-08-18 01:40:41 -07:00
Treehugger Robot
f578e9aac6 Merge "Disable HWASAN on ifunc resolvers." am: 3936985e75
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1397561

Change-Id: Id91403fee6280a835026001720c253a58f268dda
2020-08-13 22:05:10 +00:00
Elliott Hughes
58635533a0 Merge "Various coverage improvements." am: 1c502d46b3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1398334

Change-Id: I12e604e2b6c2652e6221a128779a7256ae2891ae
2020-08-13 22:04:52 +00:00
Treehugger Robot
3936985e75 Merge "Disable HWASAN on ifunc resolvers." 2020-08-13 21:58:58 +00:00
Elliott Hughes
1c502d46b3 Merge "Various coverage improvements." 2020-08-13 21:27:09 +00:00
Vy Nguyen
eb1a99cbfb Merge "Add a thread-properties API (Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)" am: d4d7efc1f8
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1360925

Change-Id: I984cdfc8e5e0273ece8dba4fa82de824f40cd2d9
2020-08-13 20:25:45 +00:00
Peter Collingbourne
03d89a7068 Disable HWASAN on ifunc resolvers.
We can't have HWASAN enabled in these resolvers because they
may be called before HWASAN is initialized.

We were previously getting away with HWASAN being enabled on these
functions because ANDROID_EXPERIMENTAL_MTE was not defined, which
let the compiler simplify away any HWASAN instrumentation in the
resolvers. But with this build flag enabled (which is currently the
case in FVP, and eventually everywhere once the MTE kernel patches
land) the resolvers end up containing an HWASAN instrumented load of
the _hwcap2 field.

Bug: 135772972
Change-Id: Iac79d02ddc81630c955e107eb7f78389aeb33879
2020-08-13 13:01:44 -07:00
Vy Nguyen
d4d7efc1f8 Merge "Add a thread-properties API (Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)" 2020-08-13 19:58:03 +00:00
Elliott Hughes
7cebf835f3 Various coverage improvements.
Mostly from extra test cases, but also:

* Move the fgets size < 0 assertion into fgets.

* Use ELF aliases for strtoq/strtouq rather than duplicating code.

* Don't check uname() succeeded, since it can't fail.

Test: treehugger
Change-Id: I2e6b3b88b0a3eb16bd68be68b9bc9f40d8043291
2020-08-12 15:52:14 -07:00
Elliott Hughes
dec52e2097 Merge "Cleanup for #inclusivefixit." am: aadcb07890
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1374048

Change-Id: I9fcd3ce31d73235eed6c51a9ffc97d14c13a5076
2020-08-12 22:16:46 +00:00
Treehugger Robot
842681cb7e Merge "Create per-API versions of the CRT objects." am: d4da7b17a2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1364178

Change-Id: Id244b76d1f718a755d2921334d4cb6c47295829c
2020-08-12 22:16:11 +00:00
Elliott Hughes
aadcb07890 Merge "Cleanup for #inclusivefixit." 2020-08-12 22:13:11 +00:00
Treehugger Robot
d4da7b17a2 Merge "Create per-API versions of the CRT objects." 2020-08-12 22:01:27 +00:00
Treehugger Robot
333d20bd0d Merge "Show coverage for libm too." am: 944fc8d38f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1397691

Change-Id: Icb95111df08d2b3a5abc7ee03a4e5c7a004b7c02
2020-08-12 19:30:34 +00:00