[compiler-rt] adfef2a - [compiler-rt][rtsan] ppoll interception. (#120366)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 09:28:56 PST 2024
Author: David CARLIER
Date: 2024-12-20T17:28:53Z
New Revision: adfef2a753d9a543ec818a445b2c6d05899cdf3d
URL: https://github.com/llvm/llvm-project/commit/adfef2a753d9a543ec818a445b2c6d05899cdf3d
DIFF: https://github.com/llvm/llvm-project/commit/adfef2a753d9a543ec818a445b2c6d05899cdf3d.diff
LOG: [compiler-rt][rtsan] ppoll interception. (#120366)
Added:
Modified:
compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index f000deb3039a8c..24e0857b966506 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -807,6 +807,17 @@ INTERCEPTOR(int, epoll_pwait, int epfd, struct epoll_event *events,
#define RTSAN_MAYBE_INTERCEPT_EPOLL_PWAIT
#endif // SANITIZER_INTERCEPT_EPOLL
+#if SANITIZER_INTERCEPT_PPOLL
+INTERCEPTOR(int, ppoll, struct pollfd *fds, nfds_t n, const struct timespec *ts,
+ const sigset_t *set) {
+ __rtsan_notify_intercepted_call("ppoll");
+ return REAL(ppoll)(fds, n, ts, set);
+}
+#define RTSAN_MAYBE_INTERCEPT_PPOLL INTERCEPT_FUNCTION(ppoll)
+#else
+#define RTSAN_MAYBE_INTERCEPT_PPOLL
+#endif
+
#if SANITIZER_INTERCEPT_KQUEUE
INTERCEPTOR(int, kqueue, void) {
__rtsan_notify_intercepted_call("kqueue");
@@ -1000,6 +1011,7 @@ void __rtsan::InitializeInterceptors() {
RTSAN_MAYBE_INTERCEPT_EPOLL_CTL;
RTSAN_MAYBE_INTERCEPT_EPOLL_WAIT;
RTSAN_MAYBE_INTERCEPT_EPOLL_PWAIT;
+ RTSAN_MAYBE_INTERCEPT_PPOLL;
RTSAN_MAYBE_INTERCEPT_KQUEUE;
RTSAN_MAYBE_INTERCEPT_KEVENT;
RTSAN_MAYBE_INTERCEPT_KEVENT64;
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 b3fb32ee8dcd41..5859ec7b5fb61b 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -1056,6 +1056,21 @@ TEST_F(EpollTest, EpollPWaitDiesWhenRealtime) {
}
#endif // SANITIZER_INTERCEPT_EPOLL
+#if SANITIZER_INTERCEPT_PPOLL
+TEST(TestRtsanInterceptors, PpollDiesWhenRealtime) {
+ struct pollfd fds[1];
+ fds[0].fd = 0;
+ fds[0].events = POLLIN;
+
+ timespec ts = {0};
+
+ auto Func = [&fds, &ts]() { ppoll(fds, 1, &ts, nullptr); };
+
+ ExpectRealtimeDeath(Func, "ppoll");
+ ExpectNonRealtimeSurvival(Func);
+}
+#endif
+
#if SANITIZER_INTERCEPT_KQUEUE
TEST(TestRtsanInterceptors, KqueueDiesWhenRealtime) {
auto Func = []() { kqueue(); };
More information about the llvm-commits
mailing list