[compiler-rt] [compiler-rt][rtsan] pathconf/fpathconf interception. (PR #134495)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 5 05:58:08 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/134495.diff
2 Files Affected:
- (modified) compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp (+12)
- (modified) compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp (+12)
``````````diff
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index e8cea21ddf9aa..7c7c7e138a652 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -712,6 +712,16 @@ INTERCEPTOR(mode_t, umask, mode_t cmask) {
return REAL(umask)(cmask);
}
+INTERCEPTOR(long, pathconf, const char *path, int name) {
+ __rtsan_notify_intercepted_call("pathconf");
+ return REAL(pathconf)(path, name);
+}
+
+INTERCEPTOR(long, fpathconf, int fildes, int name) {
+ __rtsan_notify_intercepted_call("fpathconf");
+ return REAL(fpathconf)(fildes, name);
+}
+
// Concurrency
#if SANITIZER_APPLE
#pragma clang diagnostic push
@@ -1596,6 +1606,8 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(mkdir);
INTERCEPT_FUNCTION(rmdir);
INTERCEPT_FUNCTION(umask);
+ INTERCEPT_FUNCTION(pathconf);
+ INTERCEPT_FUNCTION(fpathconf);
INTERCEPT_FUNCTION(ioctl);
RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK;
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 048da5858d665..dd55da54f8646 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -793,6 +793,18 @@ TEST_F(RtsanOpenedFileTest, FchmodDiesWhenRealtime) {
ExpectNonRealtimeSurvival(Func);
}
+TEST_F(RtsanFileTest, PathconfDiesWhenRealtime) {
+ auto Func = [this]() { pathconf(GetTemporaryFilePath(), _PC_LINK_MAX); };
+ ExpectRealtimeDeath(Func, "pathconf");
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FpathconfDiesWhenRealtime) {
+ auto Func = [this]() { fpathconf(GetOpenFd(), _PC_LINK_MAX); };
+ ExpectRealtimeDeath(Func, "fpathconf");
+ ExpectNonRealtimeSurvival(Func);
+}
+
TEST(TestRtsanInterceptors, UmaskDiesWhenRealtime) {
auto Func = []() { umask(0); };
ExpectRealtimeDeath(Func, "umask");
``````````
</details>
https://github.com/llvm/llvm-project/pull/134495
More information about the llvm-commits
mailing list