[compiler-rt] [tsan] Refine fstat{, 64} interceptors on GLIBC (PR #85612)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 01:11:57 PDT 2024
https://github.com/wangleiat created https://github.com/llvm/llvm-project/pull/85612
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.
>From f3453687490117c22f3b158cd094efbf0b796180 Mon Sep 17 00:00:00 2001
From: wanglei <wanglei at loongson.cn>
Date: Mon, 18 Mar 2024 10:32:48 +0800
Subject: [PATCH] [tsan] Refine fstat{,64} interceptors on GLIBC
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.
---
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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
More information about the llvm-commits
mailing list