Skip to content

Commit babcdb3

Browse files
committedFeb 20, 2018
Stop intercepting forkpty(3) and openpty(3) on NetBSD
Summary: forkpty(3) and openpty(3) are part of `-lutil` and we don't intend to reimplement this system library in sanitizers. Everybody using these functions will need to use a precompiled library against MSan or other desired sanitizer. Restrict these functions to Linux-only. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D43490 llvm-svn: 325585
1 parent 0d6aead commit babcdb3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎compiler-rt/lib/msan/msan_interceptors.cc

+16-2
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,9 @@ INTERCEPTOR(int, fork, void) {
11821182
return pid;
11831183
}
11841184

1185+
// NetBSD ships with openpty(3) in -lutil, that needs to be prebuilt explicitly
1186+
// with MSan.
1187+
#if SANITIZER_LINUX
11851188
INTERCEPTOR(int, openpty, int *amaster, int *aslave, char *name,
11861189
const void *termp, const void *winp) {
11871190
ENSURE_MSAN_INITED();
@@ -1193,7 +1196,14 @@ INTERCEPTOR(int, openpty, int *amaster, int *aslave, char *name,
11931196
}
11941197
return res;
11951198
}
1199+
#define MSAN_MAYBE_INTERCEPT_OPENPTY INTERCEPT_FUNCTION(openpty)
1200+
#else
1201+
#define MSAN_MAYBE_INTERCEPT_OPENPTY
1202+
#endif
11961203

1204+
// NetBSD ships with forkpty(3) in -lutil, that needs to be prebuilt explicitly
1205+
// with MSan.
1206+
#if SANITIZER_LINUX
11971207
INTERCEPTOR(int, forkpty, int *amaster, char *name, const void *termp,
11981208
const void *winp) {
11991209
ENSURE_MSAN_INITED();
@@ -1203,6 +1213,10 @@ INTERCEPTOR(int, forkpty, int *amaster, char *name, const void *termp,
12031213
__msan_unpoison(amaster, sizeof(*amaster));
12041214
return res;
12051215
}
1216+
#define MSAN_MAYBE_INTERCEPT_FORKPTY INTERCEPT_FUNCTION(forkpty)
1217+
#else
1218+
#define MSAN_MAYBE_INTERCEPT_FORKPTY
1219+
#endif
12061220

12071221
struct MSanInterceptorContext {
12081222
bool in_interceptor_scope;
@@ -1678,8 +1692,8 @@ void InitializeInterceptors() {
16781692
INTERCEPT_FUNCTION(__cxa_atexit);
16791693
INTERCEPT_FUNCTION(shmat);
16801694
INTERCEPT_FUNCTION(fork);
1681-
INTERCEPT_FUNCTION(openpty);
1682-
INTERCEPT_FUNCTION(forkpty);
1695+
MSAN_MAYBE_INTERCEPT_OPENPTY;
1696+
MSAN_MAYBE_INTERCEPT_FORKPTY;
16831697

16841698
inited = 1;
16851699
}

0 commit comments

Comments
 (0)
Please sign in to comment.