summaryrefslogtreecommitdiff
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-04-28 09:59:17 -0700
committerFangrui Song <i@maskray.me>2023-04-28 09:59:17 -0700
commitd7bead833631486e337e541e692d9b4a1ca14edd (patch)
tree423a2079ff4d0178e50e2ebd481d4ec3703d1de1 /compiler-rt/test
parentade3c6a6a88ed3a9b06c076406f196da9d3cc1b9 (diff)
downloadllvm-d7bead833631486e337e541e692d9b4a1ca14edd.tar.gz
[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
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/Linux/crypt_r.cpp36
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp32
2 files changed, 0 insertions, 68 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/crypt_r.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/crypt_r.cpp
deleted file mode 100644
index 69bfb46aa5f1..000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/crypt_r.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clangxx -O0 -g %s -lcrypt -o %t && %run %t
-
-// crypt.h is missing from Android.
-// UNSUPPORTED: android
-
-#include <assert.h>
-#include <unistd.h>
-#include <cstring>
-#include <crypt.h>
-
-int main(int argc, char **argv) {
- {
- crypt_data cd;
- cd.initialized = 0;
- char *p = crypt_r("abcdef", "xz", &cd);
- volatile size_t z = strlen(p);
- }
- {
- crypt_data cd;
- cd.initialized = 0;
- char *p = crypt_r("abcdef", "$1$", &cd);
- volatile size_t z = strlen(p);
- }
- {
- crypt_data cd;
- cd.initialized = 0;
- char *p = crypt_r("abcdef", "$5$", &cd);
- volatile size_t z = strlen(p);
- }
- {
- crypt_data cd;
- cd.initialized = 0;
- char *p = crypt_r("abcdef", "$6$", &cd);
- volatile size_t z = strlen(p);
- }
-}
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
deleted file mode 100644
index 3a8faaa1ae76..000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clangxx -O0 -g %s -o %t -lcrypt && %run %t
-
-// crypt() is missing from Android and -lcrypt from darwin.
-// UNSUPPORTED: android, darwin
-
-#include <assert.h>
-#include <unistd.h>
-#include <cstring>
-#if __has_include(<crypt.h>)
-#include <crypt.h>
-#endif
-
-int
-main (int argc, char** argv)
-{
- {
- char *p = crypt("abcdef", "xz");
- volatile size_t z = strlen(p);
- }
- {
- char *p = crypt("abcdef", "$1$");
- volatile size_t z = strlen(p);
- }
- {
- char *p = crypt("abcdef", "$5$");
- volatile size_t z = strlen(p);
- }
- {
- char *p = crypt("abcdef", "$6$");
- volatile size_t z = strlen(p);
- }
-}