diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-22 01:04:47 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-22 01:04:47 +0000 |
commit | 07da083e6bf36dd4be64a85b3461623d2488476d (patch) | |
tree | fc21546830650c084339a9892ea0aee2569408f7 | |
parent | 79c5fee02e1430bec2f75956297f5b631e70b407 (diff) | |
parent | fb16db72d227d373b0ef8cc04c7efb6091f6cc68 (diff) |
Snap for 6852218 from fb16db72d227d373b0ef8cc04c7efb6091f6cc68 to sc-release
Change-Id: Iae251c05f967d42661cc2d19a0fac485c7972cf4
-rw-r--r-- | adb/daemon/usb.cpp | 3 | ||||
-rw-r--r-- | debuggerd/Android.bp | 6 | ||||
-rw-r--r-- | debuggerd/crash_dump.cpp | 12 | ||||
-rw-r--r-- | debuggerd/debuggerd_test.cpp | 5 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/libdebuggerd/types.h | 1 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/tombstone.cpp | 3 | ||||
-rw-r--r-- | init/README.ueventd.md | 2 | ||||
-rw-r--r-- | init/firmware_handler.cpp | 46 | ||||
-rw-r--r-- | init/firmware_handler.h | 2 |
9 files changed, 71 insertions, 9 deletions
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index a66387193..50d73644d 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -584,12 +584,11 @@ struct UsbFfsConnection : public Connection { incoming_header_ = msg; } else { size_t bytes_left = incoming_header_->data_length - incoming_payload_.size(); - Block payload = std::move(block->payload); if (block->payload.size() > bytes_left) { HandleError("received too many bytes while waiting for payload"); return false; } - incoming_payload_.append(std::move(payload)); + incoming_payload_.append(std::move(block->payload)); } if (incoming_header_->data_length == incoming_payload_.size()) { diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp index ad10a1f37..99cabdd6f 100644 --- a/debuggerd/Android.bp +++ b/debuggerd/Android.bp @@ -343,6 +343,12 @@ cc_binary { apex_available: [ "com.android.runtime", ], + + product_variables: { + experimental_mte: { + cflags: ["-DANDROID_EXPERIMENTAL_MTE"], + }, + }, } cc_binary { diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index d7cb9725f..c52c6f741 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -40,6 +40,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> +#include <bionic/mte_kernel.h> #include <bionic/reserved_signals.h> #include <cutils/sockets.h> #include <log/log.h> @@ -486,6 +487,17 @@ int main(int argc, char** argv) { continue; } +#ifdef ANDROID_EXPERIMENTAL_MTE + struct iovec iov = { + &info.tagged_addr_ctrl, + sizeof(info.tagged_addr_ctrl), + }; + if (ptrace(PTRACE_GETREGSET, thread, NT_ARM_TAGGED_ADDR_CTRL, + reinterpret_cast<void*>(&iov)) == -1) { + info.tagged_addr_ctrl = -1; + } +#endif + if (thread == g_target_thread) { // Read the thread's registers along with the rest of the crash info out of the pipe. ReadCrashInfo(input_pipe, &siginfo, &info.registers, &process_info); diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 108787e4a..5ed9e57fa 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -309,6 +309,11 @@ TEST_F(CrasherTest, smoke) { std::string result; ConsumeFd(std::move(output_fd), &result); ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)"); + + if (mte_supported()) { + // Test that the default TAGGED_ADDR_CTRL value is set. + ASSERT_MATCH(result, R"(tagged_addr_ctrl: 000000000007fff3)"); + } } TEST_F(CrasherTest, tagged_fault_addr) { diff --git a/debuggerd/libdebuggerd/include/libdebuggerd/types.h b/debuggerd/libdebuggerd/include/libdebuggerd/types.h index 04c4b5c58..30e75e11d 100644 --- a/debuggerd/libdebuggerd/include/libdebuggerd/types.h +++ b/debuggerd/libdebuggerd/include/libdebuggerd/types.h @@ -23,6 +23,7 @@ struct ThreadInfo { std::unique_ptr<unwindstack::Regs> registers; + long tagged_addr_ctrl = -1; pid_t uid; diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index 7af99c94c..e1fe82b6d 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -180,6 +180,9 @@ static void dump_thread_info(log_t* log, const ThreadInfo& thread_info) { _LOG(log, logtype::HEADER, "pid: %d, tid: %d, name: %s >>> %s <<<\n", thread_info.pid, thread_info.tid, thread_info.thread_name.c_str(), thread_info.process_name.c_str()); _LOG(log, logtype::HEADER, "uid: %d\n", thread_info.uid); + if (thread_info.tagged_addr_ctrl != -1) { + _LOG(log, logtype::HEADER, "tagged_addr_ctrl: %016lx\n", thread_info.tagged_addr_ctrl); + } } static std::string get_addr_string(uint64_t addr) { diff --git a/init/README.ueventd.md b/init/README.ueventd.md index 053ebf813..0f584b2c3 100644 --- a/init/README.ueventd.md +++ b/init/README.ueventd.md @@ -86,6 +86,8 @@ Ueventd by default serves firmware requests by searching through a list of firmw for a file matching the uevent `FIRMWARE`. It then forks a process to serve this firmware to the kernel. +`/apex/*/firmware` is also searched after a list of firmware directories. + The list of firmware directories is customized by a `firmware_directories` line in a ueventd.rc file. This line takes the format of diff --git a/init/firmware_handler.cpp b/init/firmware_handler.cpp index dff7b6948..b50b4efa1 100644 --- a/init/firmware_handler.cpp +++ b/init/firmware_handler.cpp @@ -17,6 +17,7 @@ #include "firmware_handler.h" #include <fcntl.h> +#include <glob.h> #include <pwd.h> #include <signal.h> #include <stdlib.h> @@ -30,6 +31,7 @@ #include <android-base/chrono_utils.h> #include <android-base/file.h> #include <android-base/logging.h> +#include <android-base/scopeguard.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> @@ -203,25 +205,28 @@ void FirmwareHandler::ProcessFirmwareEvent(const std::string& root, } std::vector<std::string> attempted_paths_and_errors; - - int booting = IsBooting(); -try_loading_again: - attempted_paths_and_errors.clear(); - for (const auto& firmware_directory : firmware_directories_) { + auto TryLoadFirmware = [&](const std::string& firmware_directory) { std::string file = firmware_directory + firmware; unique_fd fw_fd(open(file.c_str(), O_RDONLY | O_CLOEXEC)); if (fw_fd == -1) { attempted_paths_and_errors.emplace_back("firmware: attempted " + file + ", open failed: " + strerror(errno)); - continue; + return false; } struct stat sb; if (fstat(fw_fd, &sb) == -1) { attempted_paths_and_errors.emplace_back("firmware: attempted " + file + ", fstat failed: " + strerror(errno)); - continue; + return false; } LoadFirmware(firmware, root, fw_fd, sb.st_size, loading_fd, data_fd); + return true; + }; + + int booting = IsBooting(); +try_loading_again: + attempted_paths_and_errors.clear(); + if (ForEachFirmwareDirectory(TryLoadFirmware)) { return; } @@ -242,6 +247,33 @@ try_loading_again: write(loading_fd, "-1", 2); } +bool FirmwareHandler::ForEachFirmwareDirectory( + std::function<bool(const std::string&)> handler) const { + for (const std::string& firmware_directory : firmware_directories_) { + if (std::invoke(handler, firmware_directory)) { + return true; + } + } + + glob_t glob_result; + glob("/apex/*/firmware/", GLOB_MARK, nullptr, &glob_result); + auto free_glob = android::base::make_scope_guard(std::bind(&globfree, &glob_result)); + for (size_t i = 0; i < glob_result.gl_pathc; i++) { + char* apex_firmware_directory = glob_result.gl_pathv[i]; + // Filter-out /apex/<name>@<ver> paths. The paths are bind-mounted to + // /apex/<name> paths, so unless we filter them out, we will look into the + // same apex twice. + if (strchr(apex_firmware_directory, '@')) { + continue; + } + if (std::invoke(handler, apex_firmware_directory)) { + return true; + } + } + + return false; +} + void FirmwareHandler::HandleUevent(const Uevent& uevent) { if (uevent.subsystem != "firmware" || uevent.action != "add") return; diff --git a/init/firmware_handler.h b/init/firmware_handler.h index b4138f127..8b758aee7 100644 --- a/init/firmware_handler.h +++ b/init/firmware_handler.h @@ -18,6 +18,7 @@ #include <pwd.h> +#include <functional> #include <string> #include <vector> @@ -52,6 +53,7 @@ class FirmwareHandler : public UeventHandler { const Uevent& uevent) const; std::string GetFirmwarePath(const Uevent& uevent) const; void ProcessFirmwareEvent(const std::string& root, const std::string& firmware) const; + bool ForEachFirmwareDirectory(std::function<bool(const std::string&)> handler) const; std::vector<std::string> firmware_directories_; std::vector<ExternalFirmwareHandler> external_firmware_handlers_; |