[compiler-rt] e21b804 - [compiler-rt][rtsan] socketpair interception. (#124107)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 04:52:38 PST 2025
Author: David CARLIER
Date: 2025-01-27T12:52:35Z
New Revision: e21b80464a44ef6491e44517ac59892c10ba2d6c
URL: https://github.com/llvm/llvm-project/commit/e21b80464a44ef6491e44517ac59892c10ba2d6c
DIFF: https://github.com/llvm/llvm-project/commit/e21b80464a44ef6491e44517ac59892c10ba2d6c.diff
LOG: [compiler-rt][rtsan] socketpair interception. (#124107)
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 7d8b1c84f7d1c3..68161190652637 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -1088,6 +1088,11 @@ INTERCEPTOR(int, setsockopt, int socket, int level, int option,
#define RTSAN_MAYBE_INTERCEPT_SETSOCKOPT
#endif
+INTERCEPTOR(int, socketpair, int domain, int type, int protocol, int pair[2]) {
+ __rtsan_notify_intercepted_call("socketpair");
+ return REAL(socketpair)(domain, type, protocol, pair);
+}
+
// I/O Multiplexing
INTERCEPTOR(int, poll, struct pollfd *fds, nfds_t nfds, int timeout) {
@@ -1459,6 +1464,7 @@ void __rtsan::InitializeInterceptors() {
RTSAN_MAYBE_INTERCEPT_GETPEERNAME;
RTSAN_MAYBE_INTERCEPT_GETSOCKOPT;
RTSAN_MAYBE_INTERCEPT_SETSOCKOPT;
+ INTERCEPT_FUNCTION(socketpair);
RTSAN_MAYBE_INTERCEPT_SELECT;
INTERCEPT_FUNCTION(pselect);
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 ef9ec626610d5e..59663776366bb3 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
@@ -1351,6 +1351,13 @@ TEST(TestRtsanInterceptors, SetsockoptOnASocketDiesWhenRealtime) {
}
#endif
+TEST(TestRtsanInterceptors, SocketpairDiesWhenRealtime) {
+ int pair[2]{};
+ auto Func = [&pair]() { socketpair(0, 0, 0, pair); };
+ ExpectRealtimeDeath(Func, "socketpair");
+ ExpectNonRealtimeSurvival(Func);
+}
+
/*
I/O Multiplexing
*/
More information about the llvm-commits
mailing list