[PATCH] D122724: [AddressSanitizer] Allow prefixing meminstrinsic calls in kernel mode

Marco Elver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 05:06:39 PDT 2022


melver created this revision.
melver added reviewers: glider, dvyukov, andreyknvl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
melver requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122724

Files:
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/basic.ll
  llvm/test/Instrumentation/AddressSanitizer/mem-intrinsics.ll
  llvm/test/Instrumentation/HWAddressSanitizer/mem-intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122724.419112.patch
Type: text/x-patch
Size: 11672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220330/15042201/attachment-0001.bin>


More information about the llvm-commits mailing list