Merge "Remove ld.config.txt from bionic APEX"
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp
index 7139cfa..187ee76 100644
--- a/benchmarks/bionic_benchmarks.cpp
+++ b/benchmarks/bionic_benchmarks.cpp
@@ -39,6 +39,8 @@
static const std::vector<int> kCommonSizes{
8,
+ 16,
+ 32,
64,
512,
1 * KB,
diff --git a/libc/bionic/gwp_asan_wrappers.cpp b/libc/bionic/gwp_asan_wrappers.cpp
index 03c0f97..d3e6a14 100644
--- a/libc/bionic/gwp_asan_wrappers.cpp
+++ b/libc/bionic/gwp_asan_wrappers.cpp
@@ -26,8 +26,10 @@
* SUCH DAMAGE.
*/
+#include <platform/bionic/android_unsafe_frame_pointer_chase.h>
#include <platform/bionic/malloc.h>
#include <private/bionic_arc4random.h>
+#include <private/bionic_globals.h>
#include <private/bionic_malloc_dispatch.h>
#include <stddef.h>
#include <stdint.h>
@@ -65,9 +67,15 @@
Opts.SampleRate = 2500;
Opts.InstallSignalHandlers = false;
Opts.InstallForkHandlers = true;
+ Opts.Backtrace = android_unsafe_frame_pointer_chase;
GuardedAlloc.init(Opts);
- info_log("GWP-ASan has been enabled.");
+ // TODO(b/149790891): The log line below causes ART tests to fail as they're
+ // not expecting any output. Disable the output for now.
+ // info_log("GWP-ASan has been enabled.");
+
+ __libc_shared_globals()->gwp_asan_state = GuardedAlloc.getAllocatorState();
+ __libc_shared_globals()->gwp_asan_metadata = GuardedAlloc.getMetadataRegion();
return true;
}
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index 4a7ed12..beb5ff5 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -204,21 +204,17 @@
"'strlcat' called with size bigger than buffer") {
#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
return __strlcat_chk(dst, src, size, __bos(dst));
-#endif
+#else
return __call_bypassing_fortify(strlcat)(dst, src, size);
+#endif
}
+#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
__BIONIC_FORTIFY_INLINE
size_t strlen(const char* const s __pass_object_size0) __overloadable {
-#if __ANDROID_API__ >= 17 && __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
- size_t bos = __bos0(s);
-
- if (!__bos_trivially_gt(bos, __builtin_strlen(s))) {
- return __strlen_chk(s, bos);
- }
-#endif
- return __builtin_strlen(s);
+ return __strlen_chk(s, __bos0(s));
}
+#endif
__BIONIC_FORTIFY_INLINE
char* strchr(const char* const s __pass_object_size, int c) __overloadable {
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index 4cc9bbe..6e7eb76 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -65,6 +65,10 @@
__LIBC_HIDDEN__ extern WriteProtected<libc_globals> __libc_globals;
struct abort_msg_t;
+namespace gwp_asan {
+struct AllocatorState;
+struct AllocationMetadata;
+}; // namespace gwp_asan
// Globals shared between the dynamic linker and libc.so.
struct libc_shared_globals {
@@ -96,6 +100,9 @@
// Values passed from the linker to libc.so.
const char* init_progname = nullptr;
char** init_environ = nullptr;
+
+ const gwp_asan::AllocatorState *gwp_asan_state = nullptr;
+ const gwp_asan::AllocationMetadata *gwp_asan_metadata = nullptr;
};
__LIBC_HIDDEN__ libc_shared_globals* __libc_shared_globals();
diff --git a/linker/linker_debuggerd_android.cpp b/linker/linker_debuggerd_android.cpp
index b8c82f9..42ea2b7 100644
--- a/linker/linker_debuggerd_android.cpp
+++ b/linker/linker_debuggerd_android.cpp
@@ -39,6 +39,12 @@
return __libc_shared_globals()->abort_msg;
},
.post_dump = ¬ify_gdb_of_libraries,
+ .get_gwp_asan_state = []() {
+ return __libc_shared_globals()->gwp_asan_state;
+ },
+ .get_gwp_asan_metadata = []() {
+ return __libc_shared_globals()->gwp_asan_metadata;
+ },
};
debuggerd_init(&callbacks);
}