Skip to content

Commit f59fffd

Browse files
committed
[compiler-rt][rtsan] pathconf/fpathconf interception.
1 parent 475cbf0 commit f59fffd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,16 @@ INTERCEPTOR(mode_t, umask, mode_t cmask) {
712712
return REAL(umask)(cmask);
713713
}
714714

715+
INTERCEPTOR(long, pathconf, const char *path, int name) {
716+
__rtsan_notify_intercepted_call("pathconf");
717+
return REAL(pathconf)(path, name);
718+
}
719+
720+
INTERCEPTOR(long, fpathconf, int fildes, int name) {
721+
__rtsan_notify_intercepted_call("fpathconf");
722+
return REAL(fpathconf)(fildes, name);
723+
}
724+
715725
// Concurrency
716726
#if SANITIZER_APPLE
717727
#pragma clang diagnostic push
@@ -1596,6 +1606,8 @@ void __rtsan::InitializeInterceptors() {
15961606
INTERCEPT_FUNCTION(mkdir);
15971607
INTERCEPT_FUNCTION(rmdir);
15981608
INTERCEPT_FUNCTION(umask);
1609+
INTERCEPT_FUNCTION(pathconf);
1610+
INTERCEPT_FUNCTION(fpathconf);
15991611
INTERCEPT_FUNCTION(ioctl);
16001612

16011613
RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,18 @@ TEST_F(RtsanOpenedFileTest, FchmodDiesWhenRealtime) {
793793
ExpectNonRealtimeSurvival(Func);
794794
}
795795

796+
TEST_F(RtsanFileTest, PathconfDiesWhenRealtime) {
797+
auto Func = [this]() { pathconf(GetTemporaryFilePath(), _PC_LINK_MAX); };
798+
ExpectRealtimeDeath(Func, "pathconf");
799+
ExpectNonRealtimeSurvival(Func);
800+
}
801+
802+
TEST_F(RtsanOpenedFileTest, FpathconfDiesWhenRealtime) {
803+
auto Func = [this]() { fpathconf(GetOpenFd(), _PC_LINK_MAX); };
804+
ExpectRealtimeDeath(Func, "fpathconf");
805+
ExpectNonRealtimeSurvival(Func);
806+
}
807+
796808
TEST(TestRtsanInterceptors, UmaskDiesWhenRealtime) {
797809
auto Func = []() { umask(0); };
798810
ExpectRealtimeDeath(Func, "umask");

0 commit comments

Comments
 (0)