[all-commits] [llvm/llvm-project] d7bead: [sanitizer] Remove crypt and crypt_r interceptors

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Apr 28 09:59:31 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d7bead833631486e337e541e692d9b4a1ca14edd
      https://github.com/llvm/llvm-project/commit/d7bead833631486e337e541e692d9b4a1ca14edd
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-04-28 (Fri, 28 Apr 2023)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
    R compiler-rt/test/sanitizer_common/TestCases/Linux/crypt_r.cpp
    R compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp

  Log Message:
  -----------
  [sanitizer] Remove crypt and crypt_r interceptors

>From Florian Weimer's D144073

> On GNU/Linux (glibc), the crypt and crypt_r functions are not part of the main shared object (libc.so.6), but libcrypt (with multiple possible sonames). The sanitizer libraries do not depend on libcrypt, so it can happen that during sanitizer library initialization, no real implementation will be found because the crypt, crypt_r functions are not present in the process image (yet). If its interceptors are called nevertheless, this results in a call through a null pointer when the sanitizer library attempts to forward the call to the real implementation.
>
> Many distributions have already switched to libxcrypt, a library that is separate from glibc and that can be build with sanitizers directly (avoiding the need for interceptors). This patch disables building the interceptor for glibc targets.

Let's remove crypt and crypt_r interceptors (D68431) to fix issues with
newer glibc.

For older glibc, msan will not know that an uninstrumented crypt_r call
initializes `data`, so there is a risk for false positives. However, with some
codebase survey, I think crypt_r uses are very few and the call sites typically
have a `memset(&data, 0, sizeof(data));` anyway.

Fix https://github.com/google/sanitizers/issues/1365
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2169432

Reviewed By: #sanitizers, fweimer, thesamesam, vitalybuka

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




More information about the All-commits mailing list