InitFatalReboot: Panic the system if init_fatal_panic is "true"
While handling the fatal signals and abort, exits from the signal
handler to panic the system if "androidboot.init_fatal_panic" in cmdline
is configured as "true".
Bug: 146818493
Change-Id: I59fffb7598ce981383ae24961a97fd2fd8e8d64e
diff --git a/init/reboot_utils.cpp b/init/reboot_utils.cpp
index dac0cf4..485188b 100644
--- a/init/reboot_utils.cpp
+++ b/init/reboot_utils.cpp
@@ -34,12 +34,16 @@
namespace init {
static std::string init_fatal_reboot_target = "bootloader";
+static bool init_fatal_panic = false;
void SetFatalRebootTarget() {
std::string cmdline;
android::base::ReadFileToString("/proc/cmdline", &cmdline);
cmdline = android::base::Trim(cmdline);
+ const char kInitFatalPanicString[] = "androidboot.init_fatal_panic=true";
+ init_fatal_panic = cmdline.find(kInitFatalPanicString) != std::string::npos;
+
const char kRebootTargetString[] = "androidboot.init_fatal_reboot_target=";
auto start_pos = cmdline.find(kRebootTargetString);
if (start_pos == std::string::npos) {
@@ -133,6 +137,9 @@
for (size_t i = 0; i < backtrace->NumFrames(); i++) {
LOG(ERROR) << backtrace->FormatFrameData(i);
}
+ if (init_fatal_panic) {
+ _exit(signal_number);
+ }
RebootSystem(ANDROID_RB_RESTART2, init_fatal_reboot_target);
}