[compiler-rt] [tsan] Refine fstat{, 64} interceptors on GLIBC (PR #85612)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 01:12:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: wanglei (wangleiat)
<details>
<summary>Changes</summary>
Without this patch, use-of-uninitialized value will occur. Because those architectures, which are supported by Glibc after version 2.33, will be no opportunity to implement the __fxstat{,64} interfaces.
---
Full diff: https://github.com/llvm/llvm-project/pull/85612.diff
1 Files Affected:
- (modified) compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp (+8-1)
``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 2bebe651b994e5..cbdd6d9ab44158 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -1620,7 +1620,7 @@ TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) {
#endif
TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
-#if SANITIZER_GLIBC
+#if SANITIZER_GLIBC && !__GLIBC_PREREQ(2, 33)
SCOPED_TSAN_INTERCEPTOR(__fxstat, 0, fd, buf);
if (fd > 0)
FdAccess(thr, pc, fd);
@@ -1647,10 +1647,17 @@ TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) {
#if SANITIZER_GLIBC
TSAN_INTERCEPTOR(int, fstat64, int fd, void *buf) {
+# if !__GLIBC_PREREQ(2, 33)
SCOPED_TSAN_INTERCEPTOR(__fxstat64, 0, fd, buf);
if (fd > 0)
FdAccess(thr, pc, fd);
return REAL(__fxstat64)(0, fd, buf);
+# else
+ SCOPED_TSAN_INTERCEPTOR(fstat64, fd, buf);
+ if (fd > 0)
+ FdAccess(thr, pc, fd);
+ return REAL(fstat64)(fd, buf);
+# endif
}
#define TSAN_MAYBE_INTERCEPT_FSTAT64 TSAN_INTERCEPT(fstat64)
#else
``````````
</details>
https://github.com/llvm/llvm-project/pull/85612
More information about the llvm-commits
mailing list