Revert "fdsan: make fatal by default."
This reverts commit 66b5e3ca19
.
Reason for revert: Causes installd_dexopt_test to fail. Presumably there is an existing issue which this change is turning into a hard fail, so that needs to be fixed before this can be rolled forwards. See b/139092341.
Bug: 139092341
Bug: 137788030
Change-Id: I1beccddff64c86541bc003b9b009f4046ec9cbf1
This commit is contained in:
parent
66b5e3ca19
commit
76351e3e3f
3 changed files with 26 additions and 54 deletions
|
@ -106,8 +106,30 @@ FdEntry* FdTableImpl<inline_fds>::at(size_t idx) {
|
|||
}
|
||||
|
||||
void __libc_init_fdsan() {
|
||||
constexpr auto default_level = ANDROID_FDSAN_ERROR_LEVEL_FATAL;
|
||||
android_fdsan_set_error_level_from_property(default_level);
|
||||
constexpr auto default_level = ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE;
|
||||
const prop_info* pi = __system_property_find(kFdsanPropertyName);
|
||||
if (!pi) {
|
||||
android_fdsan_set_error_level(default_level);
|
||||
return;
|
||||
}
|
||||
__system_property_read_callback(
|
||||
pi,
|
||||
[](void*, const char*, const char* value, uint32_t) {
|
||||
if (strcasecmp(value, "1") == 0 || strcasecmp(value, "fatal") == 0) {
|
||||
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_FATAL);
|
||||
} else if (strcasecmp(value, "warn") == 0) {
|
||||
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ALWAYS);
|
||||
} else if (strcasecmp(value, "warn_once") == 0) {
|
||||
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE);
|
||||
} else {
|
||||
if (strlen(value) != 0 && strcasecmp(value, "0") != 0) {
|
||||
async_safe_format_log(ANDROID_LOG_ERROR, "libc",
|
||||
"debug.fdsan set to unknown value '%s', disabling", value);
|
||||
}
|
||||
android_fdsan_set_error_level(default_level);
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static FdTable& GetFdTable() {
|
||||
|
@ -333,45 +355,6 @@ android_fdsan_error_level android_fdsan_set_error_level(android_fdsan_error_leve
|
|||
return atomic_exchange(&GetFdTable().error_level, new_level);
|
||||
}
|
||||
|
||||
android_fdsan_error_level android_fdsan_set_error_level_from_property(
|
||||
android_fdsan_error_level default_level) {
|
||||
const prop_info* pi = __system_property_find(kFdsanPropertyName);
|
||||
if (!pi) {
|
||||
return android_fdsan_set_error_level(default_level);
|
||||
}
|
||||
|
||||
struct callback_data {
|
||||
android_fdsan_error_level default_value;
|
||||
android_fdsan_error_level result;
|
||||
};
|
||||
|
||||
callback_data data;
|
||||
data.default_value = default_level;
|
||||
|
||||
__system_property_read_callback(
|
||||
pi,
|
||||
[](void* arg, const char*, const char* value, uint32_t) {
|
||||
callback_data* data = static_cast<callback_data*>(arg);
|
||||
|
||||
if (strcasecmp(value, "1") == 0 || strcasecmp(value, "fatal") == 0) {
|
||||
data->result = android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_FATAL);
|
||||
} else if (strcasecmp(value, "warn") == 0) {
|
||||
data->result = android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ALWAYS);
|
||||
} else if (strcasecmp(value, "warn_once") == 0) {
|
||||
data->result = android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE);
|
||||
} else {
|
||||
if (strlen(value) != 0 && strcasecmp(value, "0") != 0) {
|
||||
async_safe_format_log(ANDROID_LOG_ERROR, "libc",
|
||||
"debug.fdsan set to unknown value '%s', disabling", value);
|
||||
}
|
||||
data->result = android_fdsan_set_error_level(data->default_value);
|
||||
}
|
||||
},
|
||||
&data);
|
||||
|
||||
return data.result;
|
||||
}
|
||||
|
||||
int close(int fd) {
|
||||
int rc = android_fdsan_close_with_tag(fd, 0);
|
||||
if (rc == -1 && errno == EINTR) {
|
||||
|
|
|
@ -197,8 +197,4 @@ enum android_fdsan_error_level android_fdsan_get_error_level() __INTRODUCED_IN(2
|
|||
*/
|
||||
enum android_fdsan_error_level android_fdsan_set_error_level(enum android_fdsan_error_level new_level) __INTRODUCED_IN(29) __attribute__((__weak__));
|
||||
|
||||
/*
|
||||
* Set the error level to the global setting if available, or a default value.
|
||||
*/
|
||||
enum android_fdsan_error_level android_fdsan_set_error_level_from_property(enum android_fdsan_error_level default_level) __INTRODUCED_IN(30) __attribute__((__weak__));
|
||||
__END_DECLS
|
||||
|
|
|
@ -26,12 +26,9 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <android/api-level.h>
|
||||
#include <android/fdsan.h>
|
||||
|
||||
#include "linker.h"
|
||||
#include <android/api-level.h>
|
||||
#include <atomic>
|
||||
|
||||
static std::atomic<int> g_target_sdk_version(__ANDROID_API__);
|
||||
|
||||
|
@ -41,10 +38,6 @@ void set_application_target_sdk_version(int target) {
|
|||
target = __ANDROID_API__;
|
||||
}
|
||||
g_target_sdk_version = target;
|
||||
|
||||
if (target < 30) {
|
||||
android_fdsan_set_error_level_from_property(ANDROID_FDSAN_ERROR_LEVEL_WARN_ONCE);
|
||||
}
|
||||
}
|
||||
|
||||
int get_application_target_sdk_version() {
|
||||
|
|
Loading…
Reference in a new issue