summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2024-09-25 23:45:59 +0200
committerDanny Milosavljevic <dannym@friendly-machines.com>2024-09-26 00:06:11 +0200
commita2edd2a4eb04793ce755e2a44f97fa04f574cf4f (patch)
tree9a48674457a47ea359550700b29fce90ff661bef
parentcb7456eb598f9dff4dc9b6f9418b13c7a3cad172 (diff)
downloadguix-patches-a2edd2a4eb04793ce755e2a44f97fa04f574cf4f.tar
guix-patches-a2edd2a4eb04793ce755e2a44f97fa04f574cf4f.tar.gz
gnu: clang-runtime: Fix build.base-for-issue-73488
* gnu/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch: New file. * gnu/local.mk (dist_PATCH_DATA): Register it. * gnu/packages/llvm.scm (clang-runtime-12)[source]: Use it. Change-Id: I78e078ff09beb2943ba9387813ebc29069ae8f7d
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/llvm.scm2
-rw-r--r--gnu/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch129
3 files changed, 131 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 795ff822a4..507cbfebca 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1075,6 +1075,7 @@ dist_patch_DATA = \
%D%/packages/patches/clang-cling-runtime-13-glibc-2.36-compat.patch \
%D%/packages/patches/clang-runtime-asan-build-fixes.patch \
%D%/packages/patches/clang-runtime-esan-build-fixes.patch \
+ %D%/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch \
%D%/packages/patches/clang-runtime-13-glibc-2.36-compat.patch \
%D%/packages/patches/clang-runtime-14-glibc-2.36-compat.patch \
%D%/packages/patches/clang-runtime-9-glibc-2.36-compat.patch \
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 2ee1cf21c3..6c1d5bc372 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -899,7 +899,7 @@ Library.")
(clang-runtime-from-llvm
llvm-12
"1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"
- '("clang-runtime-13-glibc-2.36-compat.patch")))
+ '("clang-runtime-13-glibc-2.36-compat.patch" "clang-runtime-12-remove-crypt-interceptors.patch")))
(define-public clang-12
(clang-from-llvm llvm-12 clang-runtime-12
diff --git a/gnu/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch b/gnu/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch
new file mode 100644
index 0000000000..79c7d0166a
--- /dev/null
+++ b/gnu/packages/patches/clang-runtime-12-remove-crypt-interceptors.patch
@@ -0,0 +1,129 @@
+From 9b116160a1482c5c0c199f9c21d78a527d11d9ea Mon Sep 17 00:00:00 2001
+From: Fangrui Song <i@maskray.me>
+Date: Fri, 28 Apr 2023 09:59:17 -0700
+Subject: [PATCH] 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
+---
+ .../sanitizer_common_interceptors.inc | 37 -------------------
+ .../sanitizer_platform_interceptors.h | 2 -
+ .../sanitizer_platform_limits_posix.cpp | 8 ----
+ .../sanitizer_platform_limits_posix.h | 1 -
+ 4 files changed, 48 deletions(-)
+
+diff -ru orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_common_interceptors.inc compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_common_interceptors.inc
+--- orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_common_interceptors.inc 1970-01-01 01:00:01.000000000 +0100
++++ compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_common_interceptors.inc 2024-09-25 23:40:25.783411083 +0200
+@@ -9814,41 +9814,6 @@
+ #define INIT_GETRANDOM
+ #endif
+
+-#if SANITIZER_INTERCEPT_CRYPT
+-INTERCEPTOR(char *, crypt, char *key, char *salt) {
+- void *ctx;
+- COMMON_INTERCEPTOR_ENTER(ctx, crypt, key, salt);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1);
+- char *res = REAL(crypt)(key, salt);
+- if (res != nullptr)
+- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1);
+- return res;
+-}
+-#define INIT_CRYPT COMMON_INTERCEPT_FUNCTION(crypt);
+-#else
+-#define INIT_CRYPT
+-#endif
+-
+-#if SANITIZER_INTERCEPT_CRYPT_R
+-INTERCEPTOR(char *, crypt_r, char *key, char *salt, void *data) {
+- void *ctx;
+- COMMON_INTERCEPTOR_ENTER(ctx, crypt_r, key, salt, data);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1);
+- char *res = REAL(crypt_r)(key, salt, data);
+- if (res != nullptr) {
+- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data,
+- __sanitizer::struct_crypt_data_sz);
+- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1);
+- }
+- return res;
+-}
+-#define INIT_CRYPT_R COMMON_INTERCEPT_FUNCTION(crypt_r);
+-#else
+-#define INIT_CRYPT_R
+-#endif
+-
+ #if SANITIZER_INTERCEPT_GETENTROPY
+ INTERCEPTOR(int, getentropy, void *buf, SIZE_T buflen) {
+ void *ctx;
+@@ -10337,8 +10302,6 @@
+ INIT_GETUSERSHELL;
+ INIT_SL_INIT;
+ INIT_GETRANDOM;
+- INIT_CRYPT;
+- INIT_CRYPT_R;
+ INIT_GETENTROPY;
+ INIT_QSORT;
+ INIT_QSORT_R;
+diff -ru orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_interceptors.h
+--- orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_interceptors.h 1970-01-01 01:00:01.000000000 +0100
++++ compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_interceptors.h 2024-09-25 23:40:25.783411083 +0200
+@@ -566,8 +566,6 @@
+ #define SANITIZER_INTERCEPT_FDEVNAME SI_FREEBSD
+ #define SANITIZER_INTERCEPT_GETUSERSHELL (SI_POSIX && !SI_ANDROID)
+ #define SANITIZER_INTERCEPT_SL_INIT (SI_FREEBSD || SI_NETBSD)
+-#define SANITIZER_INTERCEPT_CRYPT (SI_POSIX && !SI_ANDROID)
+-#define SANITIZER_INTERCEPT_CRYPT_R (SI_LINUX && !SI_ANDROID)
+
+ #define SANITIZER_INTERCEPT_GETRANDOM \
+ ((SI_LINUX && __GLIBC_PREREQ(2, 25)) || SI_FREEBSD)
+diff -ru orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+--- orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp 1970-01-01 01:00:01.000000000 +0100
++++ compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp 2024-09-25 23:41:26.354728710 +0200
+@@ -151,7 +151,6 @@
+ #include <linux/serial.h>
+ #include <sys/msg.h>
+ #include <sys/ipc.h>
+-#include <crypt.h>
+ #endif // SANITIZER_ANDROID
+
+ #include <link.h>
+@@ -249,7 +248,6 @@
+ unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+- unsigned struct_crypt_data_sz = sizeof(struct crypt_data);
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+diff -ru orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+--- orig/compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h 1970-01-01 01:00:01.000000000 +0100
++++ compiler-rt-12.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h 2024-09-25 23:40:30.999352318 +0200
+@@ -295,7 +295,6 @@
+ extern unsigned struct_mq_attr_sz;
+ extern unsigned struct_timex_sz;
+ extern unsigned struct_statvfs_sz;
+-extern unsigned struct_crypt_data_sz;
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+
+ struct __sanitizer_iovec {
+