Skip to content

Commit adfef2a

Browse files
authored
[compiler-rt][rtsan] ppoll interception. (llvm#120366)
1 parent 952c8d3 commit adfef2a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-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
@@ -807,6 +807,17 @@ INTERCEPTOR(int, epoll_pwait, int epfd, struct epoll_event *events,
807807
#define RTSAN_MAYBE_INTERCEPT_EPOLL_PWAIT
808808
#endif // SANITIZER_INTERCEPT_EPOLL
809809

810+
#if SANITIZER_INTERCEPT_PPOLL
811+
INTERCEPTOR(int, ppoll, struct pollfd *fds, nfds_t n, const struct timespec *ts,
812+
const sigset_t *set) {
813+
__rtsan_notify_intercepted_call("ppoll");
814+
return REAL(ppoll)(fds, n, ts, set);
815+
}
816+
#define RTSAN_MAYBE_INTERCEPT_PPOLL INTERCEPT_FUNCTION(ppoll)
817+
#else
818+
#define RTSAN_MAYBE_INTERCEPT_PPOLL
819+
#endif
820+
810821
#if SANITIZER_INTERCEPT_KQUEUE
811822
INTERCEPTOR(int, kqueue, void) {
812823
__rtsan_notify_intercepted_call("kqueue");
@@ -1000,6 +1011,7 @@ void __rtsan::InitializeInterceptors() {
10001011
RTSAN_MAYBE_INTERCEPT_EPOLL_CTL;
10011012
RTSAN_MAYBE_INTERCEPT_EPOLL_WAIT;
10021013
RTSAN_MAYBE_INTERCEPT_EPOLL_PWAIT;
1014+
RTSAN_MAYBE_INTERCEPT_PPOLL;
10031015
RTSAN_MAYBE_INTERCEPT_KQUEUE;
10041016
RTSAN_MAYBE_INTERCEPT_KEVENT;
10051017
RTSAN_MAYBE_INTERCEPT_KEVENT64;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,21 @@ TEST_F(EpollTest, EpollPWaitDiesWhenRealtime) {
10561056
}
10571057
#endif // SANITIZER_INTERCEPT_EPOLL
10581058

1059+
#if SANITIZER_INTERCEPT_PPOLL
1060+
TEST(TestRtsanInterceptors, PpollDiesWhenRealtime) {
1061+
struct pollfd fds[1];
1062+
fds[0].fd = 0;
1063+
fds[0].events = POLLIN;
1064+
1065+
timespec ts = {0};
1066+
1067+
auto Func = [&fds, &ts]() { ppoll(fds, 1, &ts, nullptr); };
1068+
1069+
ExpectRealtimeDeath(Func, "ppoll");
1070+
ExpectNonRealtimeSurvival(Func);
1071+
}
1072+
#endif
1073+
10591074
#if SANITIZER_INTERCEPT_KQUEUE
10601075
TEST(TestRtsanInterceptors, KqueueDiesWhenRealtime) {
10611076
auto Func = []() { kqueue(); };

0 commit comments

Comments
 (0)