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
This commit is contained in:
parent
70768af0fe
commit
6bbfa26813
1 changed files with 7 additions and 0 deletions
|
@ -34,12 +34,16 @@ namespace android {
|
|||
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 @@ void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue