Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05118017 authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Automerger Merge Worker
Browse files

Merge changes from topics "I1e5610d1353b4f5b718c1259825421c0c07d7c24",...

Merge changes from topics "I1e5610d1353b4f5b718c1259825421c0c07d7c24", "I52da338347ff6b7503cf5ac80763c540695dc061", "I94e4b7124b7735b92fd83a49c80ebded3483cd4e" am: 4058c5cf am: 867184e6 am: a3c22a61 am: 1cfa3ddd am: 42466c06

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1367537

Change-Id: Id59f3cedc336ece6571b8f3180c07e591c2f4119
parents 498a2394 42466c06
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,6 @@ cc_test {
        "libcutils",
        "libdebuggerd_client",
        "liblog",
        "libminijail",
        "libnativehelper",
        "libunwindstack",
    ],
@@ -261,6 +260,7 @@ cc_test {
    static_libs: [
        "libdebuggerd",
        "libgmock",
        "libminijail",
    ],

    header_libs: [
+50 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/capability.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/resource.h>
@@ -556,6 +557,55 @@ TEST_F(CrasherTest, mte_multiple_causes) {
#endif
}

#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
static uintptr_t CreateTagMapping() {
  uintptr_t mapping =
      reinterpret_cast<uintptr_t>(mmap(nullptr, getpagesize(), PROT_READ | PROT_WRITE | PROT_MTE,
                                       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
  if (reinterpret_cast<void*>(mapping) == MAP_FAILED) {
    return 0;
  }
  __asm__ __volatile__(".arch_extension mte; stg %0, [%0]"
                       :
                       : "r"(mapping + (1ULL << 56))
                       : "memory");
  return mapping;
}
#endif

TEST_F(CrasherTest, mte_tag_dump) {
#if defined(__aarch64__) && defined(ANDROID_EXPERIMENTAL_MTE)
  if (!mte_supported()) {
    GTEST_SKIP() << "Requires MTE";
  }

  int intercept_result;
  unique_fd output_fd;
  StartProcess([&]() {
    SetTagCheckingLevelSync();
    Trap(reinterpret_cast<void *>(CreateTagMapping()));
  });

  StartIntercept(&output_fd);
  FinishCrasher();
  AssertDeath(SIGTRAP);
  FinishIntercept(&intercept_result);

  ASSERT_EQ(1, intercept_result) << "tombstoned reported failure";

  std::string result;
  ConsumeFd(std::move(output_fd), &result);

  ASSERT_MATCH(result, R"(memory near x0:
.*
.*
    01.............0 0000000000000000 0000000000000000  ................
    00.............0)");
#else
  GTEST_SKIP() << "Requires aarch64 + ANDROID_EXPERIMENTAL_MTE";
#endif
}

TEST_F(CrasherTest, LD_PRELOAD) {
  int intercept_result;
  unique_fd output_fd;