aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2024-01-23 02:41:06 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-23 02:41:06 +0000
commit5ed958220babed4fa137bf6afab0dc4d5fb25db8 (patch)
tree158f5f4eba68adeaa20d94d9626b0ff92114be9e
parent7de3d7cd2c447259ab37e2da7f16dd5fdb3cf86c (diff)
parentab5b3bd919db1c43d70e10b0adf042db0e7b017a (diff)
downloadlibbrillo-master.tar.gz
Disable fdsan after clone() am: ab5b3bd919HEADmastermain
Original change: https://android-review.googlesource.com/c/platform/external/libbrillo/+/2922590 Change-Id: I907a949535002de4c714568cbca85ffe5c015e3c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--Android.bp4
-rw-r--r--brillo/process.cc25
2 files changed, 18 insertions, 11 deletions
diff --git a/Android.bp b/Android.bp
index 8a10dc8..b999c68 100644
--- a/Android.bp
+++ b/Android.bp
@@ -171,7 +171,9 @@ cc_library {
static_libs: [
"libmodpb64",
],
- header_libs: ["libgtest_prod_headers"],
+ header_libs: [
+ "libgtest_prod_headers",
+ ],
cflags: libbrillo_CFLAGS,
export_include_dirs: ["."],
diff --git a/brillo/process.cc b/brillo/process.cc
index 5623db8..1fb33bf 100644
--- a/brillo/process.cc
+++ b/brillo/process.cc
@@ -4,6 +4,10 @@
#include "brillo/process.h"
+#ifdef __BIONIC__
+#include <android/fdsan.h>
+#endif
+
#include <fcntl.h>
#include <signal.h>
#include <stdint.h>
@@ -37,11 +41,9 @@ bool ReturnTrue() {
return true;
}
-Process::Process() {
-}
+Process::Process() {}
-Process::~Process() {
-}
+Process::~Process() {}
bool Process::ProcessExists(pid_t pid) {
return base::DirectoryExists(
@@ -55,8 +57,7 @@ ProcessImpl::ProcessImpl()
pre_exec_(base::Bind(&ReturnTrue)),
search_path_(false),
inherit_parent_signal_mask_(false),
- close_unused_file_descriptors_(false) {
-}
+ close_unused_file_descriptors_(false) {}
ProcessImpl::~ProcessImpl() {
Reset(0);
@@ -167,8 +168,7 @@ bool ProcessImpl::PopulatePipeMap() {
bool ProcessImpl::IsFileDescriptorInPipeMap(int fd) const {
for (const auto& pipe : pipe_map_) {
- if (fd == pipe.second.parent_fd_ ||
- fd == pipe.second.child_fd_ ||
+ if (fd == pipe.second.parent_fd_ || fd == pipe.second.child_fd_ ||
fd == pipe.first) {
return true;
}
@@ -259,6 +259,11 @@ bool ProcessImpl::Start() {
}
void ProcessImpl::ExecChildProcess(char** argv) {
+#ifdef __BIONIC__
+ // Disable fdsan and fdtrack post-fork, so we don't falsely trigger on
+ // processes that fork, close all of their fds, and then exec.
+ android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+#endif
// Executing inside the child process.
// Close unused file descriptors.
if (close_unused_file_descriptors_) {
@@ -361,8 +366,8 @@ int ProcessImpl::Wait() {
// kill the process that has just exited.
UpdatePid(0);
if (!WIFEXITED(status)) {
- DCHECK(WIFSIGNALED(status)) << old_pid
- << " neither exited, nor died on a signal?";
+ DCHECK(WIFSIGNALED(status))
+ << old_pid << " neither exited, nor died on a signal?";
LOG(ERROR) << "Process " << old_pid
<< " did not exit normally: " << WTERMSIG(status);
return -1;