From 8435006eea5d32f9cf895a666496b89613e2cbc1 Mon Sep 17 00:00:00 2001 From: "John F. Carr" Date: Thu, 4 Mar 2021 11:09:34 -0500 Subject: [PATCH] Disable statfs64 sanitizer wrappers on Macs. The system calls do not exist in 64-bit only operating systems and there is no obvious way to distinguish at compile time the environments that do or do not offer statfs64. --- .../lib/sanitizer_common/sanitizer_common_syscalls.inc | 4 ++++ .../sanitizer_common/sanitizer_platform_interceptors.h | 2 +- .../sanitizer_common/sanitizer_platform_limits_posix.cpp | 8 ++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc index 31ff48cfd2cf..9137a5705377 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc @@ -842,6 +842,7 @@ POST_SYSCALL(statfs)(long res, const void *path, void *buf) { } } +#if !SANITIZER_MAC PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) { if (path) PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1); @@ -852,6 +853,7 @@ POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) { if (buf) POST_WRITE(buf, struct_statfs64_sz); } } +#endif PRE_SYSCALL(fstatfs)(long fd, void *buf) {} @@ -861,6 +863,7 @@ POST_SYSCALL(fstatfs)(long res, long fd, void *buf) { } } +#if !SANITIZER_MAC PRE_SYSCALL(fstatfs64)(long fd, long sz, void *buf) {} POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) { @@ -868,6 +871,7 @@ POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) { if (buf) POST_WRITE(buf, struct_statfs64_sz); } } +#endif #endif // !SANITIZER_ANDROID PRE_SYSCALL(lstat)(const void *filename, void *statbuf) { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index 4cc69af1241d..acb710f3fc15 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -341,7 +341,7 @@ #define SANITIZER_INTERCEPT_STATFS \ (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS) #define SANITIZER_INTERCEPT_STATFS64 \ - ((SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID) + (SI_LINUX_NOT_ANDROID) #define SANITIZER_INTERCEPT_STATVFS \ (SI_FREEBSD || SI_NETBSD || SI_OPENBSD || SI_LINUX_NOT_ANDROID) #define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp index aa845df4dde4..dbb3dcec5a51 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -170,9 +170,9 @@ typedef struct user_fpregs elf_fpregset_t; namespace __sanitizer { unsigned struct_utsname_sz = sizeof(struct utsname); unsigned struct_stat_sz = sizeof(struct stat); -#if !SANITIZER_IOS +#if !SANITIZER_MAC unsigned struct_stat64_sz = sizeof(struct stat64); -#endif // !SANITIZER_IOS +#endif // !SANITIZER_MAC unsigned struct_rusage_sz = sizeof(struct rusage); unsigned struct_tm_sz = sizeof(struct tm); unsigned struct_passwd_sz = sizeof(struct passwd); @@ -196,10 +196,6 @@ namespace __sanitizer { unsigned struct_regex_sz = sizeof(regex_t); unsigned struct_regmatch_sz = sizeof(regmatch_t); -#if SANITIZER_MAC && !SANITIZER_IOS - unsigned struct_statfs64_sz = sizeof(struct statfs64); -#endif // SANITIZER_MAC && !SANITIZER_IOS - #if !SANITIZER_ANDROID unsigned struct_fstab_sz = sizeof(struct fstab); unsigned struct_statfs_sz = sizeof(struct statfs);