[all-commits] [llvm/llvm-project] 831ae4: Recommit "[libFuzzer] Link libFuzzer's own interce...

Dokyung Song via All-commits all-commits at lists.llvm.org
Thu Jul 23 09:01:52 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 831ae45e3dc609e43ba561af07670a8fe47461ef
      https://github.com/llvm/llvm-project/commit/831ae45e3dc609e43ba561af07670a8fe47461ef
  Author: Dokyung Song <dokyungs at google.com>
  Date:   2020-07-23 (Thu, 23 Jul 2020)

  Changed paths:
    M clang/include/clang/Driver/SanitizerArgs.h
    M clang/lib/Driver/SanitizerArgs.cpp
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M compiler-rt/lib/fuzzer/CMakeLists.txt
    A compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
    A compiler-rt/test/fuzzer/CustomAllocator.cpp
    A compiler-rt/test/fuzzer/custom-allocator.test
    M compiler-rt/test/fuzzer/memcmp.test
    M compiler-rt/test/fuzzer/memcmp64.test
    M compiler-rt/test/fuzzer/strcmp.test
    M compiler-rt/test/fuzzer/strncmp.test
    M compiler-rt/test/fuzzer/strstr.test

  Log Message:
  -----------
  Recommit "[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked."

Summary: libFuzzer intercepts certain library functions such as memcmp/strcmp by defining weak hooks. Weak hooks, however, are called only when other runtimes such as ASan is linked. This patch defines libFuzzer's own interceptors, which is linked into the libFuzzer executable when other runtimes are not linked, i.e., when -fsanitize=fuzzer is given, but not others.

The patch once landed but was reverted in 8ef9e2bf355d05bc81d8b0fe1e5333eec59a0a91 due to an assertion failure caused by calling an intercepted function, strncmp, while initializing the interceptors in fuzzerInit(). This issue is now fixed by calling libFuzzer's own implementation of library functions (i.e., internal_*) when the fuzzer has not been initialized yet, instead of recursively calling fuzzerInit() again.

Reviewers: kcc, morehouse, hctim

Subscribers: #sanitizers, krytarowski, mgorny, cfe-commits

Tags: #clang, #sanitizers

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




More information about the All-commits mailing list