mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-18 20:37:56 +00:00
839bfbec6d
https://gcc.gnu.org/pipermail/gcc-announce/2024/000182.html Add the new version dropping patches that have been applied upstream. Fixes #2175 Signed-off-by: Chris Packham <judge.packham@gmail.com>
125 lines
5.2 KiB
Diff
125 lines
5.2 KiB
Diff
From 95f0b5a33ef2f774e7fc0f3f85c0472b0b670996 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
|
|
---
|
|
libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc | 37 ----------
|
|
libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h | 2
|
|
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp | 2
|
|
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h | 1
|
|
4 files changed, 42 deletions(-)
|
|
|
|
--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
|
|
+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
|
|
@@ -9977,41 +9977,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;
|
|
@@ -10521,8 +10486,6 @@
|
|
INIT_GETUSERSHELL;
|
|
INIT_SL_INIT;
|
|
INIT_GETRANDOM;
|
|
- INIT_CRYPT;
|
|
- INIT_CRYPT_R;
|
|
INIT_GETENTROPY;
|
|
INIT_QSORT;
|
|
INIT_QSORT_R;
|
|
--- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
|
|
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
|
|
@@ -568,8 +568,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)
|
|
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
|
|
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
|
|
@@ -154,7 +154,6 @@
|
|
#include <linux/serial.h>
|
|
#include <sys/msg.h>
|
|
#include <sys/ipc.h>
|
|
-#include <crypt.h>
|
|
#endif // SANITIZER_ANDROID
|
|
|
|
#include <link.h>
|
|
@@ -254,7 +253,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
|
|
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
|
|
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
|
|
@@ -298,7 +298,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 {
|