[all-commits] [llvm/llvm-project] c1653b: Hwasan InitPrctl check for error using internal_is...

mmalcomson via All-commits all-commits at lists.llvm.org
Fri Feb 19 08:33:59 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c1653b8cc7bd8e7e3168089b6c6dad0aa4b6fdd6
      https://github.com/llvm/llvm-project/commit/c1653b8cc7bd8e7e3168089b6c6dad0aa4b6fdd6
  Author: Matthew Malcomson <matthew.malcomson at arm.com>
  Date:   2021-02-19 (Fri, 19 Feb 2021)

  Changed paths:
    M compiler-rt/lib/hwasan/hwasan_flags.inc
    M compiler-rt/lib/hwasan/hwasan_linux.cpp
    M compiler-rt/test/hwasan/lit.cfg.py

  Log Message:
  -----------
  Hwasan InitPrctl check for error using internal_iserror

When adding this function in https://reviews.llvm.org/D68794 I did not
notice that internal_prctl has the API of the syscall to prctl rather
than the API of the glibc (posix) wrapper.

This means that the error return value is not necessarily -1 and that
errno is not set by the call.

For InitPrctl this means that the checks do not catch running on a
kernel *without* the required ABI (not caught since I only tested this
function correctly enables the ABI when it exists).
This commit updates the two calls which check for an error condition to
use internal_iserror. That function sets a provided integer to an
equivalent errno value and returns a boolean to indicate success or not.

Tested by running on a kernel that has this ABI and on one that does
not. Verified that running on the kernel without this ABI the current
code prints the provided error message and does not attempt to run the
program. Verified that running on the kernel with this ABI the current
code does not print an error message and turns on the ABI.
This done on an x86 kernel (where the ABI does not exist), an AArch64
kernel without this ABI, and an AArch64 kernel with this ABI.

In order to keep running the testsuite on kernels that do not provide
this new ABI we add another option to the HWASAN_OPTIONS environment
variable, this option determines whether the library kills the process
if it fails to enable the relaxed syscall ABI or not.
This new flag is `fail_without_syscall_abi`.
The check-hwasan testsuite results do not change with this patch on
either x86, AArch64 without a kernel supporting this ABI, and AArch64
with a kernel supporting this ABI.

Differential Revision: https://reviews.llvm.org/D96964




More information about the All-commits mailing list