-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[tsan] Refine fstat{,64} interceptors on GLIBC #85612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-compiler-rt-sanitizer Author: wanglei (wangleiat) ChangesWithout 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:
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
|
Add @lixing-star who reported this issue to us. |
"those architectures" are not clear. I assume they include LoongArch (base version 2.36) and some RISC-V variants ( This description needs rewording. I think there may be a difference if a glibc port has a base version >= 2.33. https://maskray.me/blog/2022-05-29-glibc#buildabi-versions.h Can you describe what |
use-of-uninitialized is MSAN, but the patch is TSAN only? |
Thank you very much for your blog; I've learned a lot from it. I've attempted to modify the commit message using my limited English vocabulary. |
I apologize for my inadequate English description causing inconvenience. My intention was that on systems where __fxstat{,64} is not implemented, interception would result in calling an empty function. MSAN does not have this issue.
|
Add @abner-chenc The original issue discoverer. |
I think we should refine the interceptor conditions and use the correct symbols. I am writing a patch to properly fix this. |
The interceptors should now use |
Without this patch,
DEADLYSIGNAL
will occur on some architectures.The reason is that ports introduced in Glibc 2.33 and later will not have the opportunity to implement the
__fxstat{,64}
interfaces.For example: