Loading debuggerd/crash_dump.cpp +23 −9 Original line number Diff line number Diff line Loading @@ -142,7 +142,8 @@ static bool ptrace_interrupt(pid_t tid, int* received_signal) { return false; } static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data) { static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data, bool recoverable_gwp_asan_crash) { ATRACE_CALL(); android::base::unique_fd amfd(socket_local_client( "/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); Loading @@ -165,19 +166,32 @@ static bool activity_manager_notify(pid_t pid, int signal, const std::string& am return false; } // Activity Manager protocol: binary 32-bit network-byte-order ints for the // pid and signal number, followed by the raw text of the dump, culminating // in a zero byte that marks end-of-data. // Activity Manager protocol: // - 32-bit network-byte-order: pid // - 32-bit network-byte-order: signal number // - byte: recoverable_gwp_asan_crash // - bytes: raw text of the dump // - null terminator uint32_t datum = htonl(pid); if (!android::base::WriteFully(amfd, &datum, 4)) { if (!android::base::WriteFully(amfd, &datum, sizeof(datum))) { PLOG(ERROR) << "AM pid write failed"; return false; } datum = htonl(signal); if (!android::base::WriteFully(amfd, &datum, 4)) { PLOG(ERROR) << "AM signal write failed"; if (!android::base::WriteFully(amfd, &datum, sizeof(datum))) { PLOG(ERROR) << "AM signo write failed"; return false; } uint8_t recoverable_gwp_asan_crash_byte = recoverable_gwp_asan_crash ? 1 : 0; if (!android::base::WriteFully(amfd, &recoverable_gwp_asan_crash_byte, sizeof(recoverable_gwp_asan_crash_byte))) { PLOG(ERROR) << "AM recoverable_gwp_asan_crash_byte write failed"; return false; } if (!android::base::WriteFully(amfd, amfd_data.c_str(), amfd_data.size() + 1)) { PLOG(ERROR) << "AM data write failed"; return false; Loading Loading @@ -651,10 +665,10 @@ int main(int argc, char** argv) { } } if (fatal_signal && !recoverable_gwp_asan_crash) { if (fatal_signal) { // Don't try to notify ActivityManager if it just crashed, or we might hang until timeout. if (thread_info[target_process].thread_name != "system_server") { activity_manager_notify(target_process, signo, amfd_data); activity_manager_notify(target_process, signo, amfd_data, recoverable_gwp_asan_crash); } } Loading fastboot/fastboot.cpp +12 −19 Original line number Diff line number Diff line Loading @@ -1197,7 +1197,8 @@ static uint64_t get_partition_size(const std::string& partition) { } static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition)) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) || should_flash_in_userspace(partition)) { return; } // If overflows and negative, it should be < buf->sz. Loading Loading @@ -1559,10 +1560,10 @@ static void CancelSnapshotIfNeeded() { } } std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot) { std::string GetPartitionName(const ImageEntry& entry) { auto slot = entry.second; if (slot.empty()) { slot = current_slot; slot = get_current_slot(); } if (slot.empty()) { return entry.first->part_name; Loading @@ -1581,7 +1582,7 @@ class FlashAllTool { private: void CheckRequirements(); void DetermineSlot(); void DetermineSecondarySlot(); void CollectImages(); void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images); void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf); Loading @@ -1599,15 +1600,13 @@ void FlashAllTool::Flash() { // Change the slot first, so we boot into the correct recovery image when // using fastbootd. if (fp_->slot == "all") { if (fp_->slot_override == "all") { set_active("a"); } else { set_active(fp_->slot); set_active(fp_->slot_override); } DetermineSlot(); CollectImages(); DetermineSecondarySlot(); CancelSnapshotIfNeeded(); // First flash boot partitions. We allow this to happen either in userspace Loading Loading @@ -1652,18 +1651,12 @@ void FlashAllTool::CheckRequirements() { ::CheckRequirements({contents.data(), contents.size()}, fp_->force_flash); } void FlashAllTool::DetermineSlot() { if (fp_->slot.empty()) { fp_->current_slot = get_current_slot(); } else { fp_->current_slot = fp_->slot; } void FlashAllTool::DetermineSecondarySlot() { if (fp_->skip_secondary) { return; } if (fp_->slot != "" && fp_->slot != "all") { fp_->secondary_slot = get_other_slot(fp_->slot); if (fp_->slot_override != "" && fp_->slot_override != "all") { fp_->secondary_slot = get_other_slot(fp_->slot_override); } else { fp_->secondary_slot = get_other_slot(); } Loading @@ -1677,7 +1670,7 @@ void FlashAllTool::DetermineSlot() { void FlashAllTool::CollectImages() { for (size_t i = 0; i < images.size(); ++i) { std::string slot = fp_->slot; std::string slot = fp_->slot_override; if (images[i].IsSecondary()) { if (fp_->skip_secondary) { continue; Loading fastboot/fastboot.h +2 −3 Original line number Diff line number Diff line Loading @@ -80,8 +80,7 @@ struct FlashingPlan { bool skip_secondary = false; bool force_flash = false; std::string slot; std::string current_slot; std::string slot_override; std::string secondary_slot; fastboot::FastBootDriver* fb; }; Loading @@ -103,7 +102,7 @@ struct NetworkSerial { Result<NetworkSerial, FastbootError> ParseNetworkSerial(const std::string& serial); bool supports_AB(); std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot_); std::string GetPartitionName(const ImageEntry& entry); void flash_partition_files(const std::string& partition, const std::vector<SparsePtr>& files); int64_t get_sparse_limit(int64_t size); std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size); Loading fastboot/task.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device"; return nullptr; } if (fp->slot == "all") { if (fp->slot_override == "all") { LOG(VERBOSE) << "Cannot optimize flashing super for all slots"; return nullptr; } Loading Loading @@ -132,7 +132,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( } for (const auto& entry : os_images) { auto partition = GetPartitionName(entry, fp->current_slot); auto partition = GetPartitionName(entry); auto image = entry.first; if (!helper->AddPartition(partition, image->img_name, image->optional_if_no_image)) { Loading @@ -145,7 +145,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( // Remove images that we already flashed, just in case we have non-dynamic OS images. auto remove_if_callback = [&](const ImageEntry& entry) -> bool { return helper->WillFlash(GetPartitionName(entry, fp->current_slot)); return helper->WillFlash(GetPartitionName(entry)); }; os_images.erase(std::remove_if(os_images.begin(), os_images.end(), remove_if_callback), os_images.end()); Loading Loading @@ -201,9 +201,13 @@ WipeTask::WipeTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_ void WipeTask::Run() { std::string partition_type; if (fp_->fb->GetVar("partition-type:" + pname_, &partition_type) != fastboot::SUCCESS) { LOG(ERROR) << "wipe task partition not found: " << pname_; return; } if (partition_type.empty()) return; fp_->fb->Erase(pname_); if (fp_->fb->Erase(pname_) != fastboot::SUCCESS) { LOG(ERROR) << "wipe task erase failed with partition: " << pname_; return; } fb_perform_format(pname_, 1, partition_type, "", fp_->fs_options); } Loading
debuggerd/crash_dump.cpp +23 −9 Original line number Diff line number Diff line Loading @@ -142,7 +142,8 @@ static bool ptrace_interrupt(pid_t tid, int* received_signal) { return false; } static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data) { static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data, bool recoverable_gwp_asan_crash) { ATRACE_CALL(); android::base::unique_fd amfd(socket_local_client( "/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); Loading @@ -165,19 +166,32 @@ static bool activity_manager_notify(pid_t pid, int signal, const std::string& am return false; } // Activity Manager protocol: binary 32-bit network-byte-order ints for the // pid and signal number, followed by the raw text of the dump, culminating // in a zero byte that marks end-of-data. // Activity Manager protocol: // - 32-bit network-byte-order: pid // - 32-bit network-byte-order: signal number // - byte: recoverable_gwp_asan_crash // - bytes: raw text of the dump // - null terminator uint32_t datum = htonl(pid); if (!android::base::WriteFully(amfd, &datum, 4)) { if (!android::base::WriteFully(amfd, &datum, sizeof(datum))) { PLOG(ERROR) << "AM pid write failed"; return false; } datum = htonl(signal); if (!android::base::WriteFully(amfd, &datum, 4)) { PLOG(ERROR) << "AM signal write failed"; if (!android::base::WriteFully(amfd, &datum, sizeof(datum))) { PLOG(ERROR) << "AM signo write failed"; return false; } uint8_t recoverable_gwp_asan_crash_byte = recoverable_gwp_asan_crash ? 1 : 0; if (!android::base::WriteFully(amfd, &recoverable_gwp_asan_crash_byte, sizeof(recoverable_gwp_asan_crash_byte))) { PLOG(ERROR) << "AM recoverable_gwp_asan_crash_byte write failed"; return false; } if (!android::base::WriteFully(amfd, amfd_data.c_str(), amfd_data.size() + 1)) { PLOG(ERROR) << "AM data write failed"; return false; Loading Loading @@ -651,10 +665,10 @@ int main(int argc, char** argv) { } } if (fatal_signal && !recoverable_gwp_asan_crash) { if (fatal_signal) { // Don't try to notify ActivityManager if it just crashed, or we might hang until timeout. if (thread_info[target_process].thread_name != "system_server") { activity_manager_notify(target_process, signo, amfd_data); activity_manager_notify(target_process, signo, amfd_data, recoverable_gwp_asan_crash); } } Loading
fastboot/fastboot.cpp +12 −19 Original line number Diff line number Diff line Loading @@ -1197,7 +1197,8 @@ static uint64_t get_partition_size(const std::string& partition) { } static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition)) { if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) || should_flash_in_userspace(partition)) { return; } // If overflows and negative, it should be < buf->sz. Loading Loading @@ -1559,10 +1560,10 @@ static void CancelSnapshotIfNeeded() { } } std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot) { std::string GetPartitionName(const ImageEntry& entry) { auto slot = entry.second; if (slot.empty()) { slot = current_slot; slot = get_current_slot(); } if (slot.empty()) { return entry.first->part_name; Loading @@ -1581,7 +1582,7 @@ class FlashAllTool { private: void CheckRequirements(); void DetermineSlot(); void DetermineSecondarySlot(); void CollectImages(); void FlashImages(const std::vector<std::pair<const Image*, std::string>>& images); void FlashImage(const Image& image, const std::string& slot, fastboot_buffer* buf); Loading @@ -1599,15 +1600,13 @@ void FlashAllTool::Flash() { // Change the slot first, so we boot into the correct recovery image when // using fastbootd. if (fp_->slot == "all") { if (fp_->slot_override == "all") { set_active("a"); } else { set_active(fp_->slot); set_active(fp_->slot_override); } DetermineSlot(); CollectImages(); DetermineSecondarySlot(); CancelSnapshotIfNeeded(); // First flash boot partitions. We allow this to happen either in userspace Loading Loading @@ -1652,18 +1651,12 @@ void FlashAllTool::CheckRequirements() { ::CheckRequirements({contents.data(), contents.size()}, fp_->force_flash); } void FlashAllTool::DetermineSlot() { if (fp_->slot.empty()) { fp_->current_slot = get_current_slot(); } else { fp_->current_slot = fp_->slot; } void FlashAllTool::DetermineSecondarySlot() { if (fp_->skip_secondary) { return; } if (fp_->slot != "" && fp_->slot != "all") { fp_->secondary_slot = get_other_slot(fp_->slot); if (fp_->slot_override != "" && fp_->slot_override != "all") { fp_->secondary_slot = get_other_slot(fp_->slot_override); } else { fp_->secondary_slot = get_other_slot(); } Loading @@ -1677,7 +1670,7 @@ void FlashAllTool::DetermineSlot() { void FlashAllTool::CollectImages() { for (size_t i = 0; i < images.size(); ++i) { std::string slot = fp_->slot; std::string slot = fp_->slot_override; if (images[i].IsSecondary()) { if (fp_->skip_secondary) { continue; Loading
fastboot/fastboot.h +2 −3 Original line number Diff line number Diff line Loading @@ -80,8 +80,7 @@ struct FlashingPlan { bool skip_secondary = false; bool force_flash = false; std::string slot; std::string current_slot; std::string slot_override; std::string secondary_slot; fastboot::FastBootDriver* fb; }; Loading @@ -103,7 +102,7 @@ struct NetworkSerial { Result<NetworkSerial, FastbootError> ParseNetworkSerial(const std::string& serial); bool supports_AB(); std::string GetPartitionName(const ImageEntry& entry, std::string& current_slot_); std::string GetPartitionName(const ImageEntry& entry); void flash_partition_files(const std::string& partition, const std::vector<SparsePtr>& files); int64_t get_sparse_limit(int64_t size); std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size); Loading
fastboot/task.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( LOG(VERBOSE) << "Cannot optimize flashing super on non-AB device"; return nullptr; } if (fp->slot == "all") { if (fp->slot_override == "all") { LOG(VERBOSE) << "Cannot optimize flashing super for all slots"; return nullptr; } Loading Loading @@ -132,7 +132,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( } for (const auto& entry : os_images) { auto partition = GetPartitionName(entry, fp->current_slot); auto partition = GetPartitionName(entry); auto image = entry.first; if (!helper->AddPartition(partition, image->img_name, image->optional_if_no_image)) { Loading @@ -145,7 +145,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize( // Remove images that we already flashed, just in case we have non-dynamic OS images. auto remove_if_callback = [&](const ImageEntry& entry) -> bool { return helper->WillFlash(GetPartitionName(entry, fp->current_slot)); return helper->WillFlash(GetPartitionName(entry)); }; os_images.erase(std::remove_if(os_images.begin(), os_images.end(), remove_if_callback), os_images.end()); Loading Loading @@ -201,9 +201,13 @@ WipeTask::WipeTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_ void WipeTask::Run() { std::string partition_type; if (fp_->fb->GetVar("partition-type:" + pname_, &partition_type) != fastboot::SUCCESS) { LOG(ERROR) << "wipe task partition not found: " << pname_; return; } if (partition_type.empty()) return; fp_->fb->Erase(pname_); if (fp_->fb->Erase(pname_) != fastboot::SUCCESS) { LOG(ERROR) << "wipe task erase failed with partition: " << pname_; return; } fb_perform_format(pname_, 1, partition_type, "", fp_->fs_options); }