[all-commits] [llvm/llvm-project] 016e60: sanitizer_common: guard the wcslen interceptor cod...

Thurston Dang via All-commits all-commits at lists.llvm.org
Thu May 18 23:44:12 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 016e604f6e1680588160008ba10618f58097e57e
      https://github.com/llvm/llvm-project/commit/016e604f6e1680588160008ba10618f58097e57e
  Author: Thurston Dang <thurston at google.com>
  Date:   2023-05-19 (Fri, 19 May 2023)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

  Log Message:
  -----------
  sanitizer_common: guard the wcslen interceptor code with SANITIZER_INTERCEPT_WCSLEN

This patch adds the #if SANITIZER_INTERCEPT_ guard for wcslen, similarly to how all the other
functions are guarded. It was the only missing SANITIZER_INTERCEPT_ guard [1].

This missing guard was discovered while investigating the stage2/hwasan check failure of https://reviews.llvm.org/D150708 ("hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]"), that was seen in https://lab.llvm.org/buildbot/#/builders/236/builds/4069. llvm_build_hwasan/unittests/ADT/./ADTTests had crashed with a backtrace of:
...
A disassembly of the binary showed that wcslen interception was present (since it was not guarded by SANITIZER_INTERCEPT_WCSLEN); howver, since INIT_WCSLEN was not called, REAL(wcslen) was null, resulting in the null pointer dereference.

[1] I checked this using "egrep '^#[ ]*define[ ]+(INIT_.*)' sanitizer_common_interceptors.inc | tr -s ' ' | sed -r 's/^# /#/' | cut -d ' ' -f 2 | sort | uniq -c | grep -v '^[ ]*2[ ]'"
The other matches are {INIT_PTHREAD_SETNAME_NP, INIT_QSORT, INIT_SHA2_INTECEPTORS(LEN), INIT_TLS_GET_ADDR, INIT_WAIT4}, which all have good reasons for not having exactly two cases.

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




More information about the All-commits mailing list