[GWP-ASan] Use recoverable everywhere
Use recoverable mode for system processes and system apps as well.
Given we're a sampled bug detector anyway, why not let these processes
continue. This might save some user experience if something ends up
crashing that requires a SysUI reboot (like system_server). And, hey,
starting up processes is expensive.
Bug: N/A
Test: atest CtsGwpAsanTestCases
Change-Id: Ia6be4fcf3b3ed55a3089587d060aba7ab318cf97
diff --git a/libc/bionic/gwp_asan_wrappers.cpp b/libc/bionic/gwp_asan_wrappers.cpp
index 251633d..11f7ced 100644
--- a/libc/bionic/gwp_asan_wrappers.cpp
+++ b/libc/bionic/gwp_asan_wrappers.cpp
@@ -258,14 +258,14 @@
options->Backtrace = android_unsafe_frame_pointer_chase;
options->SampleRate = kDefaultSampleRate;
options->MaxSimultaneousAllocations = kDefaultMaxAllocs;
+ options->Recoverable = true;
+ GwpAsanRecoverable = true;
- *process_sample_rate = 1;
- if (mallopt_options.desire == Action::TURN_ON_WITH_SAMPLING) {
+ if (mallopt_options.desire == Action::TURN_ON_WITH_SAMPLING ||
+ mallopt_options.desire == Action::TURN_ON_FOR_APP_SAMPLED_NON_CRASHING) {
*process_sample_rate = kDefaultProcessSampling;
- } else if (mallopt_options.desire == Action::TURN_ON_FOR_APP_SAMPLED_NON_CRASHING) {
- *process_sample_rate = kDefaultProcessSampling;
- options->Recoverable = true;
- GwpAsanRecoverable = true;
+ } else {
+ *process_sample_rate = 1;
}
}
@@ -403,7 +403,7 @@
/* default */ kDefaultMaxAllocs / frequency_multiplier;
}
- bool recoverable = false;
+ bool recoverable = true;
if (GetGwpAsanBoolOption(&recoverable, mallopt_options, kRecoverableSystemSysprop,
kRecoverableAppSysprop, kRecoverableTargetedSyspropPrefix,
kRecoverableEnvVar, "recoverable")) {
diff --git a/libc/platform/bionic/malloc.h b/libc/platform/bionic/malloc.h
index a06b8ee..ffc6d4a 100644
--- a/libc/platform/bionic/malloc.h
+++ b/libc/platform/bionic/malloc.h
@@ -152,6 +152,10 @@
// mode, and bug reports will be created by debuggerd, however the process
// will recover and continue to function as if the memory safety bug wasn't
// detected.
+ //
+ // In Android 15, this is the same as TURN_ON_WITH_SAMPLING, as GWP-ASan is
+ // only ever used in non-crashing mode (even for platform executables and
+ // system apps).
TURN_ON_FOR_APP_SAMPLED_NON_CRASHING,
};