Skip to content

Commit cbe1fac

Browse files
authored
Revert "[compiler-rt][rtsan] stat api interception. (#128430)"
This reverts commit 4d928d5.
1 parent 6053ca0 commit cbe1fac

File tree

2 files changed

+2
-74
lines changed

2 files changed

+2
-74
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -285,45 +285,6 @@ INTERCEPTOR(int, unlinkat, int fd, const char *pathname, int flag) {
285285
return REAL(unlinkat)(fd, pathname, flag);
286286
}
287287

288-
INTERCEPTOR(int, stat, const char *pathname, struct stat *s) {
289-
__rtsan_notify_intercepted_call("stat");
290-
return REAL(stat)(pathname, s);
291-
}
292-
293-
INTERCEPTOR(int, lstat, const char *pathname, struct stat *s) {
294-
__rtsan_notify_intercepted_call("lstat");
295-
return REAL(lstat)(pathname, s);
296-
}
297-
298-
INTERCEPTOR(int, fstat, int fd, struct stat *s) {
299-
__rtsan_notify_intercepted_call("fstat");
300-
return REAL(fstat)(fd, s);
301-
}
302-
303-
#if !SANITIZER_APPLE // deprecated for darwin
304-
INTERCEPTOR(int, stat64, const char *pathname, struct stat64 *s) {
305-
__rtsan_notify_intercepted_call("stat64");
306-
return REAL(stat64)(pathname, s);
307-
}
308-
309-
INTERCEPTOR(int, lstat64, const char *pathname, struct stat64 *s) {
310-
__rtsan_notify_intercepted_call("lstat64");
311-
return REAL(lstat64)(pathname, s);
312-
}
313-
314-
INTERCEPTOR(int, fstat64, int fd, struct stat64 *s) {
315-
__rtsan_notify_intercepted_call("fstat64");
316-
return REAL(fstat64)(fd, s);
317-
}
318-
#define RTSAN_MAYBE_INTERCEPT_STAT64 INTERCEPT_FUNCTION(stat64)
319-
#define RTSAN_MAYBE_INTERCEPT_LSTAT64 INTERCEPT_FUNCTION(lstat64)
320-
#define RTSAN_MAYBE_INTERCEPT_FSTAT64 INTERCEPT_FUNCTION(fstat64)
321-
#else
322-
#define RTSAN_MAYBE_INTERCEPT_STAT64
323-
#define RTSAN_MAYBE_INTERCEPT_LSTAT64
324-
#define RTSAN_MAYBE_INTERCEPT_FSTAT64
325-
#endif
326-
327288
// Streams
328289

329290
INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) {
@@ -1476,12 +1437,6 @@ void __rtsan::InitializeInterceptors() {
14761437
RTSAN_MAYBE_INTERCEPT_READLINKAT;
14771438
INTERCEPT_FUNCTION(unlink);
14781439
INTERCEPT_FUNCTION(unlinkat);
1479-
INTERCEPT_FUNCTION(stat);
1480-
INTERCEPT_FUNCTION(lstat);
1481-
INTERCEPT_FUNCTION(fstat);
1482-
RTSAN_MAYBE_INTERCEPT_STAT64;
1483-
RTSAN_MAYBE_INTERCEPT_LSTAT64;
1484-
RTSAN_MAYBE_INTERCEPT_FSTAT64;
14851440
INTERCEPT_FUNCTION(fopen);
14861441
RTSAN_MAYBE_INTERCEPT_FOPEN64;
14871442
RTSAN_MAYBE_INTERCEPT_FREOPEN64;

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
401401
ASSERT_THAT(fd, Ne(-1));
402402

403403
auto Func = [fd]() {
404-
struct flock lock{};
404+
struct flock lock {};
405405
lock.l_type = F_RDLCK;
406406
lock.l_whence = SEEK_SET;
407407
lock.l_start = 0;
@@ -735,7 +735,7 @@ TEST(TestRtsanInterceptors, IoctlBehavesWithOutputPointer) {
735735
GTEST_SKIP();
736736
}
737737

738-
struct ifreq ifr{};
738+
struct ifreq ifr {};
739739
strncpy(ifr.ifr_name, ifaddr->ifa_name, IFNAMSIZ - 1);
740740

741741
int retval = ioctl(sock, SIOCGIFADDR, &ifr);
@@ -875,33 +875,6 @@ TEST_F(RtsanOpenedFileTest, UnlinkatDiesWhenRealtime) {
875875
ExpectNonRealtimeSurvival(Func);
876876
}
877877

878-
TEST_F(RtsanOpenedFileTest, StatDiesWhenRealtime) {
879-
auto Func = [&]() {
880-
struct stat s{};
881-
stat(GetTemporaryFilePath(), &s);
882-
};
883-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("stat"));
884-
ExpectNonRealtimeSurvival(Func);
885-
}
886-
887-
TEST_F(RtsanOpenedFileTest, LstatDiesWhenRealtime) {
888-
auto Func = [&]() {
889-
struct stat s{};
890-
lstat(GetTemporaryFilePath(), &s);
891-
};
892-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("lstat"));
893-
ExpectNonRealtimeSurvival(Func);
894-
}
895-
896-
TEST_F(RtsanOpenedFileTest, FstatDiesWhenRealtime) {
897-
auto Func = [&]() {
898-
struct stat s{};
899-
fstat(GetOpenFd(), &s);
900-
};
901-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fstat"));
902-
ExpectNonRealtimeSurvival(Func);
903-
}
904-
905878
TEST_F(RtsanFileTest, FcloseDiesWhenRealtime) {
906879
FILE *f = fopen(GetTemporaryFilePath(), "w");
907880
EXPECT_THAT(f, Ne(nullptr));

0 commit comments

Comments
 (0)