Mitch Phillips fca8871ca3 Add SA_EXPOSE_TAGBITS to crashpad's signal handler.
SA_EXPOSE_TAGBITS is a Linux >= 5.11 feature that allows si_addr to
contain the upper tag bits. This is a feature that allows signal
handlers to see the full upper address bits on aarch64, which consist of
TBI and MTE nibbles. For MTE, preserving these bits is of significant
importance, as it allows for precise use-after-free and buffer-overflow
diagnosis that's impossible without seeing these bits in the fault
address.

We unconditionally enable this feature on all kernels, as it's ignored
when unsupported (even on older kernels).

Tested on:
 1. Linux x86 host, which is a no-op.
 2. Android device with Linux 4.14, which is a no-op.
 3. Android device with Linux 5.15, which passes. For posterity, my
    config was:
 |  $ gn args out_arm64
 |  target_os = "android"
 |  android_ndk_root = "~/Android.sdk/ndk/21.4.7075529"
 |  android_api_level = 26
 |  target_cpu = "arm64"
 |  # NDK builds push libc++_shared.so, which is not present on newer Android
 |  # versions, so I hacked the runner to push the file. Maybe this should be
 |  # upstreamed at some point as well.
 |  $ git diff
 |  diff --git a/build/run_tests.py b/build/run_tests.py
 |  index 8ad19e34..64269c90 100755
 |  --- a/build/run_tests.py
 |  +++ b/build/run_tests.py
 |  @@ -273,7 +273,8 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
 |          _adb_shell(adb_mkdir_command)
 |
 |          # Push the test binary and any other build output to the device.
 |  -        local_test_build_artifacts = []
 |  +        local_test_build_artifacts = [
 |  +            '~/Android.sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so']
 |          for artifact in test_build_artifacts:
 |              local_test_build_artifacts.append(os.path.join(
 |                  binary_dir, artifact))
 |  @@ -294,6 +295,7 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
 |          # The list of TERM values comes from Google Test’s
 |          # googletest/src/gtest.cc testing::internal::ShouldUseColor().
 |          env = {'CRASHPAD_TEST_DATA_ROOT': device_temp_dir}
 |  +        env = {'LD_LIBRARY_PATH': device_out_dir}
 |          gtest_color = os.environ.get('GTEST_COLOR')
 |          if gtest_color in ('auto', None):
 |              if (sys.stdout.isatty() and
 |  $ ninja -C out_arm64 && python build/run_tests.py out_arm64/ \
 |    --gtest_filter=*StartHandlerForSelfTestSuite*

Change-Id: I293b36fcd08ffaca593dae8042299a39756defa0
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4024204
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mitch Phillips <mitchp@google.com>
2022-11-14 23:44:52 +00:00
..