Refresh zend_mm shadow key on fork

The shadow key is refreshed when resetting the memory manager between two
requests. But in forking SAPIs the first request of a child process inherits the
shadow key of the parent. As a result, a leak of the shadow key during the first
request of one process gives away the shadow key used during the first request
of other processes. This makes the key refresh mechanism less useful.

Here I ensure that we refresh the shadow key after a fork. We can not reset the
manager as there may be active allocations. Instead, we have to recompute shadow
pointers with the new key.

Closes GH-16765
This commit is contained in:
Arnaud Le Blanc 2024-11-12 18:07:41 +01:00
parent 8e38f6d1c6
commit c561f7da85
No known key found for this signature in database
12 changed files with 85 additions and 13 deletions

View file

@ -2530,6 +2530,7 @@ static void php_cli_server_startup_workers(void) {
#if defined(HAVE_PRCTL) || defined(HAVE_PROCCTL)
php_cli_server_worker_install_pdeathsig();
#endif
php_child_init();
return;
} else {
php_cli_server_workers[php_cli_server_worker] = pid;