diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-07 16:40:48 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-07 16:46:02 +0000 |
commit | 7632dede7b9b3b2be609866c6f814ae4d3aa079b (patch) | |
tree | 92c3e7757690a8b6a96d35c753fff7979cc102ca /src/crypto/CryptonightR_JIT.c | |
parent | gtest: build fix for NetBSD (diff) | |
download | monero-7632dede7b9b3b2be609866c6f814ae4d3aa079b.tar.xz |
crypto: fix PaX issue on NetBSD with CNv4 JIT
Diffstat (limited to 'src/crypto/CryptonightR_JIT.c')
-rw-r--r-- | src/crypto/CryptonightR_JIT.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/crypto/CryptonightR_JIT.c b/src/crypto/CryptonightR_JIT.c index 68258a959..ee8f3f36f 100644 --- a/src/crypto/CryptonightR_JIT.c +++ b/src/crypto/CryptonightR_JIT.c @@ -4,6 +4,9 @@ #include <string.h> #include <stdio.h> #include <unistd.h> +#if !(defined(_MSC_VER) || defined(__MINGW32__)) +#include <sys/mman.h> +#endif #include "int-util.h" #include "hash-ops.h" @@ -58,6 +61,11 @@ int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_f uint8_t* JIT_code = (uint8_t*) buf; const uint8_t* JIT_code_end = JIT_code + buf_size; +#if !(defined(_MSC_VER) || defined(__MINGW32__)) + if (mprotect((void*)buf, buf_size, PROT_READ | PROT_WRITE)) + return 1; +#endif + APPEND_CODE(prologue, sizeof(prologue)); uint32_t prev_rot_src = 0xFFFFFFFFU; @@ -101,6 +109,11 @@ int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_f APPEND_CODE(epilogue, sizeof(epilogue)); +#if !(defined(_MSC_VER) || defined(__MINGW32__)) + if (mprotect((void*)buf, buf_size, PROT_READ | PROT_EXEC)) + return 1; +#endif + __builtin___clear_cache((char*)buf, (char*)JIT_code); return 0; |