Skip to content

Commit 06daf0d

Browse files
committed
opcache fixing w/x pages creation on freebsd 13.1 and above.
By default, the system allows these but admin can disable them system wide. However the procctl api permits to control it per process.
1 parent 1cd2170 commit 06daf0d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ sys/file.h \
401401
sys/mman.h \
402402
sys/mount.h \
403403
sys/poll.h \
404+
sys/procctl.h \
404405
sys/resource.h \
405406
sys/select.h \
406407
sys/socket.h \
@@ -587,6 +588,7 @@ mmap \
587588
nice \
588589
nl_langinfo \
589590
poll \
591+
procctl \
590592
putenv \
591593
scandir \
592594
setitimer \

ext/opcache/shared_alloc_mmap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include <mach/vm_statistics.h>
3434
#endif
3535

36+
#ifdef HAVE_SYS_PROCCTL_H
37+
#include <sys/procctl.h>
38+
#endif
39+
3640
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
3741
# define MAP_ANONYMOUS MAP_ANON
3842
#endif
@@ -45,6 +49,12 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
4549
zend_shared_segment *shared_segment;
4650
int flags = PROT_READ | PROT_WRITE, fd = -1;
4751
void *p;
52+
#if defined(HAVE_PROCCTL) && defined(PROC_WXMAP_CTL)
53+
int enable_wxmap = PROC_WX_MAPPINGS_PERMIT;
54+
if (procctl(P_PID, getpid(), PROC_WXMAP_CTL, &enable_wxmap) == -1) {
55+
return ALLOC_FAILURE;
56+
}
57+
#endif
4858
#ifdef PROT_MPROTECT
4959
flags |= PROT_MPROTECT(PROT_EXEC);
5060
#endif

0 commit comments

Comments
 (0)