Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,17 @@ INTERCEPTOR(int, shm_unlink, const char *name) {
return REAL(shm_unlink)(name);
}

#if !SANITIZER_APPLE
// is supported by freebsd too
INTERCEPTOR(int, memfd_create, const char *path, unsigned int flags) {
__rtsan_notify_intercepted_call("memfd_create");
return REAL(memfd_create)(path, flags);
}
#define RTSAN_MAYBE_INTERCEPT_MEMFD_CREATE INTERCEPT_FUNCTION(memfd_create)
#else
#define RTSAN_MAYBE_INTERCEPT_MEMFD_CREATE
#endif

// Sockets
INTERCEPTOR(int, getaddrinfo, const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res) {
Expand Down Expand Up @@ -1465,6 +1476,7 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(mincore);
INTERCEPT_FUNCTION(shm_open);
INTERCEPT_FUNCTION(shm_unlink);
RTSAN_MAYBE_INTERCEPT_MEMFD_CREATE;
RTSAN_MAYBE_INTERCEPT_MEMALIGN;
RTSAN_MAYBE_INTERCEPT_PVALLOC;

Expand Down
8 changes: 8 additions & 0 deletions compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ TEST(TestRtsanInterceptors, ShmUnlinkDiesWhenRealtime) {
ExpectNonRealtimeSurvival(Func);
}

#if !SANITIZER_APPLE
TEST(TestRtsanInterceptors, MemfdCreateDiesWhenRealtime) {
auto Func = []() { memfd_create("/rtsan_test_memfd_create", MFD_CLOEXEC); };
ExpectRealtimeDeath(Func, "memfd_create");
ExpectNonRealtimeSurvival(Func);
}
#endif

/*
Sleeping
*/
Expand Down