aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-09 06:16:42 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-09 06:16:42 +0000
commit13d273beb5cfe78b4047deeaacb938aea336add9 (patch)
tree0425e2528abca3f7f9af7b664013837d0dd37320
parent6de15b7b0e5e70f2e51bbe22120362b7ea11c2ce (diff)
parentbbe7c690f1fbe714fe06c2107cb3e4d25bc791f2 (diff)
downloadbionic-android13-frc-media-swcodec-release.tar.gz
Snap for 8558685 from bbe7c690f1fbe714fe06c2107cb3e4d25bc791f2 to tm-frc-media-swcodec-releaset_frc_swc_330443040t_frc_swc_330443010android13-frc-media-swcodec-release
Change-Id: I23f58f10c1d442db8610f083458cbafede372093
-rw-r--r--libc/SECCOMP_ALLOWLIST_COMMON.TXT4
-rw-r--r--libc/bionic/spawn.cpp5
-rw-r--r--tests/gwp_asan_test.cpp2
3 files changed, 10 insertions, 1 deletions
diff --git a/libc/SECCOMP_ALLOWLIST_COMMON.TXT b/libc/SECCOMP_ALLOWLIST_COMMON.TXT
index 6650d7e32..0366fdf0f 100644
--- a/libc/SECCOMP_ALLOWLIST_COMMON.TXT
+++ b/libc/SECCOMP_ALLOWLIST_COMMON.TXT
@@ -31,6 +31,8 @@ int seccomp:seccomp(unsigned int operation, unsigned int flags, void *args) all
int open:open(const char*, int, ...) arm,x86,x86_64
int stat64:stat64(const char*, struct stat64*) arm,x86
ssize_t readlink:readlink(const char*, char*, size_t) arm,x86,x86_64
+# Needed by ubsan in T? (http://b/229989971)
+int stat(const char*, struct stat*) arm,x86,x86_64
#
# Useful new syscalls which we don't yet use in bionic.
@@ -74,3 +76,5 @@ int futex_time64(int*, int, int, const timespec64*, int*, int) lp32
int sched_rr_get_interval_time64(pid_t, timespec64*) lp32
# Since Linux 5.4, not in glibc. Probed for and conditionally used by ART.
int userfaultfd(int) all
+# Since Linux 5.9, used by POSIX_SPAWN_CLOEXEC_DEFAULT
+int close_range(unsigned int, unsigned int, int) all
diff --git a/libc/bionic/spawn.cpp b/libc/bionic/spawn.cpp
index 314a05669..59f763138 100644
--- a/libc/bionic/spawn.cpp
+++ b/libc/bionic/spawn.cpp
@@ -30,10 +30,12 @@
#include <errno.h>
#include <fcntl.h>
+#include <linux/close_range.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
+#include <sys/syscall.h>
#include <unistd.h>
#include <android/fdsan.h>
@@ -49,6 +51,9 @@ static int set_cloexec(int i) {
// mark all open fds except stdin/out/err as close-on-exec
static int cloexec_except_stdioe() {
+ // requires 5.11+ or ACK 5.10-T kernel, otherwise returns ENOSYS or EINVAL
+ if (!syscall(SYS_close_range, 3, ~0U, CLOSE_RANGE_CLOEXEC)) return 0;
+
// unfortunately getrlimit can lie:
// - both soft and hard limits can be lowered to 0, with fds still open, so it can underestimate
// - in practice it usually is some really large value (like 32K or more)
diff --git a/tests/gwp_asan_test.cpp b/tests/gwp_asan_test.cpp
index b442f51e6..b2c7780b1 100644
--- a/tests/gwp_asan_test.cpp
+++ b/tests/gwp_asan_test.cpp
@@ -43,7 +43,7 @@ void RunGwpAsanTest(const char* test_name) {
std::string filter_arg = "--gtest_filter=";
filter_arg += test_name;
std::string exec(testing::internal::GetArgvs()[0]);
- eh.SetArgs({exec.c_str(), "--gtest_also_run_disabled_tests", filter_arg.c_str()});
+ eh.SetArgs({exec.c_str(), "--gtest_also_run_disabled_tests", filter_arg.c_str(), nullptr});
eh.Run([&]() { execve(exec.c_str(), eh.GetArgs(), eh.GetEnv()); },
/* expected_exit_status */ 0,
// |expected_output_regex|, ensure at least one test ran: