[php-src] PR #20461: [PoC] Use Memory Protection Keys to manage memory permissions of opcache SHM and JIT buffer
| From: | arnaud-lb | Date: | Wed, 12 Nov 2025 13:13:45 +0000 |
| Subject: | [php-src] PR #20461: [PoC] Use Memory Protection Keys to manage memory permissions of opcache SHM and JIT buffer | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34025@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20461
Author: arnaud-lb
This follows https://github.com/dstogov/ir/commit/fe83fdf224ef05b11b3db21c0fae1f3d4d05b836.
Opcache uses mprotect() to flip the writeable flag when
opcache.protect_memory is on.
JIT uses mprotect() to exchange the writeable and executable flags.
Here I use pkeys to replace the mprotect() calls.
Unfortunately I didn't see notable improvements in benchmarks.
IIRC opcache.protect_memory has a considerable impact on CI (maybe fuzzer too), so this
may profit that.
See
* https://docs.kernel.org/core-api/protection-keys.html
* https://www.gnu.org/software/libc/manual/html_node/Memory-Protection.html
* https://man7.org/linux/man-pages/man7/pkeys.7.html
cc @dstogov