Skip to content

Revert "[compiler-rt][rtsan] stat api interception." #128465

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

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

cjappl
Copy link
Contributor

@cjappl cjappl commented Feb 24, 2025

Reverts #128430

Reverting this as I could repro the failure here:

Hi @devnexen I believe this change is causing failures on a bot. Any idea what might be causing the problems?
https://lab.llvm.org/staging/#/builders/202/builds/1324

#128430 (comment)

@cjappl cjappl requested a review from devnexen February 24, 2025 05:21
@cjappl cjappl merged commit 58035b5 into main Feb 24, 2025
8 of 12 checks passed
@cjappl cjappl deleted the revert-128430-rtsan_stat branch February 24, 2025 05:21
@llvmbot
Copy link
Member

llvmbot commented Feb 24, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Chris Apple (cjappl)

Changes

Reverts llvm/llvm-project#128430

Reverting this as I could repro the failure here:

> Hi @devnexen I believe this change is causing failures on a bot. Any idea what might be causing the problems?
> https://lab.llvm.org/staging/#/builders/202/builds/1324

#128430 (comment)


Full diff: https://github.com/llvm/llvm-project/pull/128465.diff

2 Files Affected:

  • (modified) compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp (-45)
  • (modified) compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp (+2-29)
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index 57a01396b8123..5b9e992639f55 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -285,45 +285,6 @@ INTERCEPTOR(int, unlinkat, int fd, const char *pathname, int flag) {
   return REAL(unlinkat)(fd, pathname, flag);
 }
 
-INTERCEPTOR(int, stat, const char *pathname, struct stat *s) {
-  __rtsan_notify_intercepted_call("stat");
-  return REAL(stat)(pathname, s);
-}
-
-INTERCEPTOR(int, lstat, const char *pathname, struct stat *s) {
-  __rtsan_notify_intercepted_call("lstat");
-  return REAL(lstat)(pathname, s);
-}
-
-INTERCEPTOR(int, fstat, int fd, struct stat *s) {
-  __rtsan_notify_intercepted_call("fstat");
-  return REAL(fstat)(fd, s);
-}
-
-#if !SANITIZER_APPLE // deprecated for darwin
-INTERCEPTOR(int, stat64, const char *pathname, struct stat64 *s) {
-  __rtsan_notify_intercepted_call("stat64");
-  return REAL(stat64)(pathname, s);
-}
-
-INTERCEPTOR(int, lstat64, const char *pathname, struct stat64 *s) {
-  __rtsan_notify_intercepted_call("lstat64");
-  return REAL(lstat64)(pathname, s);
-}
-
-INTERCEPTOR(int, fstat64, int fd, struct stat64 *s) {
-  __rtsan_notify_intercepted_call("fstat64");
-  return REAL(fstat64)(fd, s);
-}
-#define RTSAN_MAYBE_INTERCEPT_STAT64 INTERCEPT_FUNCTION(stat64)
-#define RTSAN_MAYBE_INTERCEPT_LSTAT64 INTERCEPT_FUNCTION(lstat64)
-#define RTSAN_MAYBE_INTERCEPT_FSTAT64 INTERCEPT_FUNCTION(fstat64)
-#else
-#define RTSAN_MAYBE_INTERCEPT_STAT64
-#define RTSAN_MAYBE_INTERCEPT_LSTAT64
-#define RTSAN_MAYBE_INTERCEPT_FSTAT64
-#endif
-
 // Streams
 
 INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) {
@@ -1476,12 +1437,6 @@ void __rtsan::InitializeInterceptors() {
   RTSAN_MAYBE_INTERCEPT_READLINKAT;
   INTERCEPT_FUNCTION(unlink);
   INTERCEPT_FUNCTION(unlinkat);
-  INTERCEPT_FUNCTION(stat);
-  INTERCEPT_FUNCTION(lstat);
-  INTERCEPT_FUNCTION(fstat);
-  RTSAN_MAYBE_INTERCEPT_STAT64;
-  RTSAN_MAYBE_INTERCEPT_LSTAT64;
-  RTSAN_MAYBE_INTERCEPT_FSTAT64;
   INTERCEPT_FUNCTION(fopen);
   RTSAN_MAYBE_INTERCEPT_FOPEN64;
   RTSAN_MAYBE_INTERCEPT_FREOPEN64;
diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
index fc5a2f771ddb7..d1c5a94c12213 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -401,7 +401,7 @@ TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
   ASSERT_THAT(fd, Ne(-1));
 
   auto Func = [fd]() {
-    struct flock lock{};
+    struct flock lock {};
     lock.l_type = F_RDLCK;
     lock.l_whence = SEEK_SET;
     lock.l_start = 0;
@@ -735,7 +735,7 @@ TEST(TestRtsanInterceptors, IoctlBehavesWithOutputPointer) {
     GTEST_SKIP();
   }
 
-  struct ifreq ifr{};
+  struct ifreq ifr {};
   strncpy(ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ - 1);
 
   int retval = ioctl(sock, SIOCGIFADDR, &ifr);
@@ -875,33 +875,6 @@ TEST_F(RtsanOpenedFileTest, UnlinkatDiesWhenRealtime) {
   ExpectNonRealtimeSurvival(Func);
 }
 
-TEST_F(RtsanOpenedFileTest, StatDiesWhenRealtime) {
-  auto Func = [&]() {
-    struct stat s{};
-    stat(GetTemporaryFilePath(), &s);
-  };
-  ExpectRealtimeDeath(Func, MAYBE_APPEND_64("stat"));
-  ExpectNonRealtimeSurvival(Func);
-}
-
-TEST_F(RtsanOpenedFileTest, LstatDiesWhenRealtime) {
-  auto Func = [&]() {
-    struct stat s{};
-    lstat(GetTemporaryFilePath(), &s);
-  };
-  ExpectRealtimeDeath(Func, MAYBE_APPEND_64("lstat"));
-  ExpectNonRealtimeSurvival(Func);
-}
-
-TEST_F(RtsanOpenedFileTest, FstatDiesWhenRealtime) {
-  auto Func = [&]() {
-    struct stat s{};
-    fstat(GetOpenFd(), &s);
-  };
-  ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fstat"));
-  ExpectNonRealtimeSurvival(Func);
-}
-
 TEST_F(RtsanFileTest, FcloseDiesWhenRealtime) {
   FILE *f = fopen(GetTemporaryFilePath(), "w");
   EXPECT_THAT(f, Ne(nullptr));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants