[all-commits] [llvm/llvm-project] b8e49f: [AddressSanitizer] Allow prefixing memintrinsic ca...

Marco Elver via All-commits all-commits at lists.llvm.org
Thu Mar 31 02:22:55 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b8e49fdcb1455922b433fd1e8049c1588a570fd7
      https://github.com/llvm/llvm-project/commit/b8e49fdcb1455922b433fd1e8049c1588a570fd7
  Author: Marco Elver <elver at google.com>
  Date:   2022-03-31 (Thu, 31 Mar 2022)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    M llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
    M llvm/test/Instrumentation/AddressSanitizer/basic.ll
    A llvm/test/Instrumentation/AddressSanitizer/mem-intrinsics.ll
    M llvm/test/Instrumentation/HWAddressSanitizer/mem-intrinsics.ll

  Log Message:
  -----------
  [AddressSanitizer] Allow prefixing memintrinsic calls in kernel mode

Allow receiving memcpy/memset/memmove instrumentation by using __asan or
__hwasan prefixed versions for AddressSanitizer and HWAddressSanitizer
respectively when compiling in kernel mode, by passing params
-asan-kernel-mem-intrinsic-prefix or -hwasan-kernel-mem-intrinsic-prefix.

By default the kernel-specialized versions of both passes drop the
prefixes for calls generated by memintrinsics. This assumes that all
locations that can lower the intrinsics to libcalls can safely be
instrumented. This unfortunately is not the case when implicit calls to
memintrinsics are inserted by the compiler in no_sanitize functions [1].

To solve the issue, normal memcpy/memset/memmove need to be
uninstrumented, and instrumented code should instead use the prefixed
versions. This also aligns with ASan behaviour in user space.

[1] https://lore.kernel.org/lkml/Yj2yYFloadFobRPx@lakrids/

Reviewed By: glider

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




More information about the All-commits mailing list