Skip to content

Commit 4bf9c1f

Browse files
committed
sapi/phpdbg: Update of userfaultfd workflow.
unpriviliged_userfaultfd is set to 0 by default. Since Linux 5.11 handling memory ranges from the user-space is allowed with the `UFFD_USER_MODE_ONLY` fd open mode flag.
1 parent 72b2524 commit 4bf9c1f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sapi/phpdbg/phpdbg_watch.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,14 @@ void phpdbg_setup_watchpoints(void) {
14721472
PHPDBG_G(watch_tmp) = NULL;
14731473

14741474
#ifdef HAVE_USERFAULTFD_WRITEFAULT
1475-
PHPDBG_G(watch_userfaultfd) = syscall(SYS_userfaultfd, O_CLOEXEC);
1475+
int flags = O_CLOEXEC;
1476+
#ifdef UFFD_USER_MODE_ONLY
1477+
// unpriviliged userfaultfd being disabled by default,
1478+
// with this flag it allows ranges from the user space
1479+
// being reported.
1480+
flags |= UFFD_USER_MODE_ONLY;
1481+
#endif
1482+
PHPDBG_G(watch_userfaultfd) = syscall(SYS_userfaultfd, flags);
14761483
if (PHPDBG_G(watch_userfaultfd) < 0) {
14771484
PHPDBG_G(watch_userfaultfd) = 0;
14781485
} else {

0 commit comments

Comments
 (0)