diff options
| author | Anton Lindqvist <anton@basename.se> | 2019-06-06 04:13:28 +0200 |
|---|---|---|
| committer | Greg Steuck <gnezdo@google.com> | 2019-06-05 19:13:28 -0700 |
| commit | a547defcdc2fffb71a997c3bff70cecbc1572c3d (patch) | |
| tree | 546aeb3d1237a59fa4a2fb5abde5f4699cd17ca9 /executor/executor_bsd.h | |
| parent | bfb4a51e30c8c04658a2675333b9b89a9d327c4a (diff) | |
executor: add cover protection support to OpenBSD (#1215)
Diffstat (limited to 'executor/executor_bsd.h')
| -rw-r--r-- | executor/executor_bsd.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h index 45d0cfe84..9acd12bb9 100644 --- a/executor/executor_bsd.h +++ b/executor/executor_bsd.h @@ -10,6 +10,10 @@ #include <sys/types.h> #include <unistd.h> +#if GOOS_openbsd +#include <sys/sysctl.h> +#endif + static void os_init(int argc, char** argv, void* data, size_t data_size) { #if GOOS_openbsd @@ -88,6 +92,16 @@ static void cover_protect(cover_t* cov) if (page_size > 0) mprotect(cov->data + page_size, mmap_alloc_size - page_size, PROT_READ); +#elif GOOS_openbsd + int mib[2], page_size; + size_t len; + size_t mmap_alloc_size = kCoverSize * sizeof(uintptr_t); + mib[0] = CTL_HW; + mib[1] = HW_PAGESIZE; + len = sizeof(page_size); + if (sysctl(mib, ARRAY_SIZE(mib), &page_size, &len, NULL, 0) != -1) + mprotect(cov->data + page_size, mmap_alloc_size - page_size, + PROT_READ); #endif } @@ -96,6 +110,9 @@ static void cover_unprotect(cover_t* cov) #if GOOS_freebsd size_t mmap_alloc_size = kCoverSize * KCOV_ENTRY_SIZE; mprotect(cov->data, mmap_alloc_size, PROT_READ | PROT_WRITE); +#elif GOOS_openbsd + size_t mmap_alloc_size = kCoverSize * sizeof(uintptr_t); + mprotect(cov->data, mmap_alloc_size, PROT_READ | PROT_WRITE); #endif } |
