Skip to content

Commit 39a7d49

Browse files
committed
ext/opcache JIT: attempt to fix EPERM on unprotecting dasm buffer.
despite disabling protection before mprotect call, we still get an EPERM with ZTS build we set all PROT*flags. removing typo in mapped segments (flag in the wrong place even tough the os most likely discard it).
1 parent 7096eff commit 39a7d49

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,12 +4629,7 @@ ZEND_EXT_API void zend_jit_unprotect(void)
46294629
#ifdef HAVE_MPROTECT
46304630
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
46314631
int opts = PROT_READ | PROT_WRITE;
4632-
#ifdef ZTS
4633-
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
4634-
if (zend_write_protect) {
4635-
pthread_jit_write_protect_np(0);
4636-
}
4637-
#endif
4632+
#if defined(ZTS) && (!defined(__APPLE__) || !defined(__aarch64__))
46384633
opts |= PROT_EXEC;
46394634
#endif
46404635
if (mprotect(dasm_buf, dasm_size, opts) != 0) {

ext/opcache/shared_alloc_mmap.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
180180
#ifdef PROT_MAX
181181
flags |= PROT_MAX(PROT_READ | PROT_WRITE | PROT_EXEC);
182182
#endif
183-
#ifdef MAP_JIT
184-
flags |= MAP_JIT;
185-
#endif
186183
#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__)) && !defined(__SANITIZE_ADDRESS__)
187184
void *hint = find_prefered_mmap_base(requested_size);
188185
if (hint != MAP_FAILED) {

0 commit comments

Comments
 (0)