core: update from upstream
Followed instructions from go/nnapi-dep-instructions.
No manual changes / interventions have been made.
$ git merge origin/master --no-ff
$ git push origin HEAD:refs/for/master
BUG=chromium:1182060
TEST=cq passes
Submitting directly since this repo is not mapped into ChromeOS, but is
used by copybara to populate other repos (libutils, libcutils).
Exempt-From-Owner-Approval: This is a forked repo
Change-Id: I6bf469f2e36264b3d93069b300b7723059e532c4
GitOrigin-RevId: 78faf8a6c10fd46247acc3362d09d81f90b0a51b
diff --git a/Android.bp b/Android.bp
index cf809f1..b38818a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,48 +1,51 @@
-//
-// Copyright (C) 2008 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+package {
+ default_applicable_licenses: ["system_core_libcutils_license"],
+}
+
+license {
+ name: "system_core_libcutils_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-MIT", // strlcpy.c
+ ],
+ license_text: [
+ "NOTICE",
+ ],
+}
filegroup {
name: "android_filesystem_config_header",
srcs: ["include/private/android_filesystem_config.h"],
}
-// some files must not be compiled when building against Mingw
-// they correspond to features not used by our host development tools
-// which are also hard or even impossible to port to native Win32
-libcutils_nonwindows_sources = [
- "fs.cpp",
- "hashmap.cpp",
- "multiuser.cpp",
- "str_parms.cpp",
-]
+cc_defaults {
+ name: "libcutils_defaults",
+ cflags: [
+ "-Wno-exit-time-destructors",
+ ],
-cc_library_headers {
- name: "libcutils_headers",
- vendor_available: true,
product_available: true,
- recovery_available: true,
ramdisk_available: true,
+ recovery_available: true,
+ vendor_available: true,
vendor_ramdisk_available: true,
+
host_supported: true,
+ native_bridge_supported: true,
+
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
min_sdk_version: "29",
- native_bridge_supported: true,
+}
+
+cc_library_headers {
+ name: "libcutils_headers",
+ defaults: ["libcutils_defaults"],
+
export_include_dirs: ["include"],
target: {
vendor: {
@@ -63,18 +66,7 @@
// Socket specific parts of libcutils that are safe to statically link into an APEX.
cc_library {
name: "libcutils_sockets",
- vendor_available: true,
- product_available: true,
- recovery_available: true,
- ramdisk_available: true,
- vendor_ramdisk_available: true,
- host_supported: true,
- native_bridge_supported: true,
- apex_available: [
- "//apex_available:platform",
- "//apex_available:anyapex",
- ],
- min_sdk_version: "29",
+ defaults: ["libcutils_defaults"],
export_include_dirs: ["include"],
@@ -145,29 +137,28 @@
},
}
+// some files must not be compiled when building against Mingw
+// they correspond to features not used by our host development tools
+// which are also hard or even impossible to port to native Win32
+libcutils_nonwindows_sources = [
+ "fs.cpp",
+ "hashmap.cpp",
+ "multiuser.cpp",
+ "str_parms.cpp",
+]
+
cc_library {
name: "libcutils",
- vendor_available: true,
- product_available: true,
+ defaults: ["libcutils_defaults"],
vndk: {
enabled: true,
support_system_process: true,
},
- recovery_available: true,
- vendor_ramdisk_available: true,
- host_supported: true,
- apex_available: [
- "//apex_available:platform",
- "//apex_available:anyapex",
- ],
- min_sdk_version: "29",
- native_bridge_supported: true,
srcs: [
"config_utils.cpp",
"canned_fs_config.cpp",
"iosched_policy.cpp",
"load_file.cpp",
- "memory.cpp",
"native_handle.cpp",
"properties.cpp",
"record_stream.cpp",
@@ -179,10 +170,14 @@
linux_bionic: {
enabled: true,
},
+ linux: {
+ srcs: [
+ "fs_config.cpp",
+ ],
+ },
not_windows: {
srcs: libcutils_nonwindows_sources + [
"ashmem-host.cpp",
- "fs_config.cpp",
"trace-host.cpp",
],
},
@@ -202,7 +197,6 @@
srcs: libcutils_nonwindows_sources + [
"android_reboot.cpp",
"ashmem-dev.cpp",
- "fs_config.cpp",
"klog.cpp",
"partition_utils.cpp",
"qtaguid.cpp",
@@ -210,9 +204,6 @@
"uevent.cpp",
],
},
- bionic: {
- header_libs: ["bionic_libc_platform_headers"],
- },
android_arm: {
sanitize: {
@@ -263,7 +254,6 @@
header_libs: [
"libbase_headers",
"libcutils_headers",
- "libutils_headers",
"libprocessgroup_headers",
],
export_header_lib_headers: [
diff --git a/fs_config.cpp b/fs_config.cpp
index 79c3abc..54eeeac 100644
--- a/fs_config.cpp
+++ b/fs_config.cpp
@@ -37,7 +37,6 @@
#include <android-base/strings.h>
#include <log/log.h>
#include <private/android_filesystem_config.h>
-#include <utils/Compat.h>
#include "fs_config.h"
diff --git a/include/cutils/memory.h b/include/cutils/memory.h
index 0fba53c..c6476c1 100644
--- a/include/cutils/memory.h
+++ b/include/cutils/memory.h
@@ -28,9 +28,6 @@
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
-// Disables memory mitigations for the entire process, and logs appropriately.
-void process_disable_memory_mitigations();
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/include/cutils/threads.h b/include/cutils/threads.h
index 0f7f8a8..0082c6c 100644
--- a/include/cutils/threads.h
+++ b/include/cutils/threads.h
@@ -31,7 +31,9 @@
//
// Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows.
//
+#if !defined(__GLIBC__) || __GLIBC__ >= 2 && __GLIBC_MINOR__ < 32
extern pid_t gettid();
+#endif
#ifdef __cplusplus
}
diff --git a/include/cutils/trace.h b/include/cutils/trace.h
index 793e2ce..ef426ff 100644
--- a/include/cutils/trace.h
+++ b/include/cutils/trace.h
@@ -104,14 +104,6 @@
void atrace_update_tags();
/**
- * Set whether the process is debuggable. By default the process is not
- * considered debuggable. If the process is not debuggable then application-
- * level tracing is not allowed unless the ro.debuggable system property is
- * set to '1'.
- */
-void atrace_set_debuggable(bool debuggable);
-
-/**
* Set whether tracing is enabled for the current process. This is used to
* prevent tracing within the Zygote process.
*/
diff --git a/memory.cpp b/memory.cpp
deleted file mode 100644
index f526520..0000000
--- a/memory.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cutils/memory.h>
-
-#include <log/log.h>
-
-#ifdef __BIONIC__
-#include <bionic/malloc.h>
-#endif
-
-void process_disable_memory_mitigations() {
- bool success = false;
-#ifdef __BIONIC__
- // TODO(b/158870657) is fixed and scudo is used globally, we can assert when an
- // an error is returned.
-
- success = android_mallopt(M_DISABLE_MEMORY_MITIGATIONS, nullptr, 0);
-#endif
-
- if (success) {
- ALOGI("Disabled memory mitigations for process.");
- } else {
- ALOGE("Could not disable memory mitigations for process.");
- }
-}
diff --git a/threads.cpp b/threads.cpp
index 8cfee1e..6ece7a3 100644
--- a/threads.cpp
+++ b/threads.cpp
@@ -25,8 +25,9 @@
#include <windows.h>
#endif
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) || defined(__GLIBC__) && __GLIBC_MINOR__ >= 32
// No definition needed for Android because we'll just pick up bionic's copy.
+// No definition needed for Glibc >= 2.32 because it exposes its own copy.
#else
pid_t gettid() {
#if defined(__APPLE__)
diff --git a/trace-dev.inc b/trace-dev.inc
index 6543426..3b459e0 100644
--- a/trace-dev.inc
+++ b/trace-dev.inc
@@ -21,6 +21,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <fnmatch.h>
#include <limits.h>
#include <pthread.h>
#include <stdatomic.h>
@@ -51,7 +52,6 @@
atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
int atrace_marker_fd = -1;
uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
-static bool atrace_is_debuggable = false;
static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -95,15 +95,6 @@
return atrace_enabled_tags;
}
-// Set whether this process is debuggable, which determines whether
-// application-level tracing is allowed when the ro.debuggable system property
-// is not set to '1'.
-void atrace_set_debuggable(bool debuggable)
-{
- atrace_is_debuggable = debuggable;
- atrace_update_tags();
-}
-
// Check whether the given command line matches one of the comma-separated
// values listed in the app_cmdlines property.
static bool atrace_is_cmdline_match(const char* cmdline)
@@ -116,7 +107,7 @@
for (int i = 0; i < count; i++) {
snprintf(buf, sizeof(buf), "debug.atrace.app_%d", i);
property_get(buf, value, "");
- if (strcmp(value, "*") == 0 || strcmp(value, cmdline) == 0) {
+ if (fnmatch(value, cmdline, FNM_NOESCAPE) == 0) {
return true;
}
}
@@ -127,24 +118,21 @@
// Determine whether application-level tracing is enabled for this process.
static bool atrace_is_app_tracing_enabled()
{
- bool sys_debuggable = property_get_bool("ro.debuggable", 0);
bool result = false;
- if (sys_debuggable || atrace_is_debuggable) {
- // Check whether tracing is enabled for this process.
- FILE * file = fopen("/proc/self/cmdline", "re");
- if (file) {
- char cmdline[4096];
- if (fgets(cmdline, sizeof(cmdline), file)) {
- result = atrace_is_cmdline_match(cmdline);
- } else {
- ALOGE("Error reading cmdline: %s (%d)", strerror(errno), errno);
- }
- fclose(file);
+ // Check whether tracing is enabled for this process.
+ FILE * file = fopen("/proc/self/cmdline", "re");
+ if (file) {
+ char cmdline[4096];
+ if (fgets(cmdline, sizeof(cmdline), file)) {
+ result = atrace_is_cmdline_match(cmdline);
} else {
- ALOGE("Error opening /proc/self/cmdline: %s (%d)", strerror(errno),
- errno);
+ ALOGE("Error reading cmdline: %s (%d)", strerror(errno), errno);
}
+ fclose(file);
+ } else {
+ ALOGE("Error opening /proc/self/cmdline: %s (%d)", strerror(errno),
+ errno);
}
return result;