Reenable fdsan in the zygote post-fork.
By default, fdsan is disabled after forking to avoid breaking 'fork();
close(0..1024); exec(...)'. Reenable it in the zygote manually.
Bug: http://b/110100358
Test: booted walleye-aosp
Change-Id: I8706e4153e4e91306f50d215a62fe02d445082e1
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 8cb2dcd..9b9f704 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -24,6 +24,7 @@
#include <sstream>
#include <string>
+#include <android/fdsan.h>
#include <fcntl.h>
#include <grp.h>
#include <inttypes.h>
@@ -789,6 +790,8 @@
fail_fn(error_msg);
}
+ android_fdsan_error_level fdsan_error_level = android_fdsan_get_error_level();
+
pid_t pid = fork();
if (pid == 0) {
@@ -805,6 +808,9 @@
if (!gOpenFdTable->ReopenOrDetach(&error_msg)) {
fail_fn(error_msg);
}
+
+ // Turn fdsan back on.
+ android_fdsan_set_error_level(fdsan_error_level);
}
// We blocked SIGCHLD prior to a fork, we unblock it here.