[PATCH] D44035: OpenBSD pthread interceptor subset
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 14:33:14 PST 2018
devnexen updated this revision to Diff 136856.
https://reviews.llvm.org/D44035
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -3590,7 +3590,7 @@
// * GNU version returns message pointer, which points to either buf or some
// static storage.
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || \
- SANITIZER_MAC || SANITIZER_ANDROID || SANITIZER_NETBSD
+ SANITIZER_MAC || SANITIZER_ANDROID || SANITIZER_NETBSD || SANITIZER_OPENBSD
// POSIX version. Spec is not clear on whether buf is NULL-terminated.
// At least on OSX, buf contents are valid even when the call fails.
INTERCEPTOR(int, strerror_r, int errnum, char *buf, SIZE_T buflen) {
@@ -4405,25 +4405,36 @@
#endif
#if SANITIZER_INTERCEPT_PTHREAD_ATTR_GET
-INTERCEPTOR_PTHREAD_ATTR_GET(detachstate, sizeof(int))
-INTERCEPTOR_PTHREAD_ATTR_GET(guardsize, sizeof(SIZE_T))
-INTERCEPTOR_PTHREAD_ATTR_GET(schedparam, struct_sched_param_sz)
-INTERCEPTOR_PTHREAD_ATTR_GET(schedpolicy, sizeof(int))
-INTERCEPTOR_PTHREAD_ATTR_GET(scope, sizeof(int))
-INTERCEPTOR_PTHREAD_ATTR_GET(stacksize, sizeof(SIZE_T))
-INTERCEPTOR(int, pthread_attr_getstack, void *attr, void **addr, SIZE_T *size) {
- void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, pthread_attr_getstack, attr, addr, size);
- // FIXME: under ASan the call below may write to freed memory and corrupt
- // its metadata. See
- // https://github.com/google/sanitizers/issues/321.
- int res = REAL(pthread_attr_getstack)(attr, addr, size);
- if (!res) {
- if (addr) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addr, sizeof(*addr));
- if (size) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, size, sizeof(*size));
- }
- return res;
-}
+#define COMMON_INTERCEPTOR_PTHREAD_ATTR_GET \
+INTERCEPTOR_PTHREAD_ATTR_GET(detachstate, sizeof(int)) \
+INTERCEPTOR_PTHREAD_ATTR_GET(guardsize, sizeof(SIZE_T)) \
+INTERCEPTOR_PTHREAD_ATTR_GET(scope, sizeof(int)) \
+INTERCEPTOR_PTHREAD_ATTR_GET(stacksize, sizeof(SIZE_T)) \
+INTERCEPTOR(int, pthread_attr_getstack, void *attr, void **addr, SIZE_T *size) { \
+ void *ctx; \
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_attr_getstack, attr, addr, size); \
+ // FIXME: under ASan the call below may write to freed memory and corrupt \
+ // its metadata. See \
+ // https://github.com/google/sanitizers/issues/321. \
+ int res = REAL(pthread_attr_getstack)(attr, addr, size); \
+ if (!res) { \
+ if (addr) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addr, sizeof(*addr)); \
+ if (size) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, size, sizeof(*size)); \
+ } \
+ return res; \
+}
+
+#if !SANITIZER_OPENBSD
+#define SANITIZER_INTERCEPTOR_PTHREAD_ATTR_GET \
+COMMON_INTERCEPTOR_PTHREAD_ATTR_GET \
+INTERCEPTOR_PTHREAD_ATTR_GET(schedparam, struct_sched_param_sz) \
+INTERCEPTOR_PTHREAD_ATTR_GET(schedpolicy, sizeof(int))
+#else
+#define SANITIZER_INTERCEPTOR_PTHREAD_ATTR_GET \
+COMMON_INTERCEPTOR_PTHREAD_ATTR_GET
+#endif
+
+SANITIZER_INTERCEPTOR_PTHREAD_ATTR_GET
// We may need to call the real pthread_attr_getstack from the run-time
// in sanitizer_common, but we don't want to include the interception headers
@@ -4436,14 +4447,21 @@
} // extern "C"
} // namespace __sanitizer
-#define INIT_PTHREAD_ATTR_GET \
+#define COMMON_INIT_PTHREAD_ATTR_GET \
COMMON_INTERCEPT_FUNCTION(pthread_attr_getdetachstate); \
COMMON_INTERCEPT_FUNCTION(pthread_attr_getguardsize); \
- COMMON_INTERCEPT_FUNCTION(pthread_attr_getschedparam); \
- COMMON_INTERCEPT_FUNCTION(pthread_attr_getschedpolicy); \
COMMON_INTERCEPT_FUNCTION(pthread_attr_getscope); \
COMMON_INTERCEPT_FUNCTION(pthread_attr_getstacksize); \
COMMON_INTERCEPT_FUNCTION(pthread_attr_getstack);
+
+#if !SANITIZER_OPENBSD
+#define INIT_PTHREAD_ATTR_GET \
+ COMMON_INIT_PTHREAD_ATTR_GET \
+ COMMON_INTERCEPT_FUNCTION(pthread_attr_getschedparam); \
+ COMMON_INTERCEPT_FUNCTION(pthread_attr_getschedpolicy); \
+#else
+#define INIT_PTHREAD_ATTR_GET COMMON_INIT_PTHREAD_ATTR_GET
+#endif
#else
#define INIT_PTHREAD_ATTR_GET
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44035.136856.patch
Type: text/x-patch
Size: 4933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/b84c386f/attachment.bin>
More information about the llvm-commits
mailing list