[php-src] PHP-8.2: Fix possible segfault with 0x0 shared opcache base
| From: | Bob Weinand | Date: | Mon, 18 Mar 2024 16:35:44 +0000 |
| Subject: | [php-src] PHP-8.2: Fix possible segfault with 0x0 shared opcache base | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127777@lists.php.net to get a copy of this message | ||
Author: Bob Weinand (bwoebi)
Date: 2024-03-18T17:18:33+01:00
Commit: https://github.com/php/php-src/commit/6fb8b9d721d0e0e001780cc0d1f11842aedcff83
Raw diff: https://github.com/php/php-src/commit/6fb8b9d721d0e0e001780cc0d1f11842aedcff83.diff
Fix possible segfault with 0x0 shared opcache base
Moving the minimum base of the shared opcache memory to the second huge page to avoid a possible 0x0
base, which may cause all sorts of segfaults.
This is not a problem on most systems which have a mmap_min_addr which is non-zero, but e.g. WSL1
doesn't have a minimum mapping address.
Changed paths:
M ext/opcache/shared_alloc_mmap.c
Diff:
diff --git a/ext/opcache/shared_alloc_mmap.c b/ext/opcache/shared_alloc_mmap.c
index 6f01f1d631b7..1840b214705f 100644
--- a/ext/opcache/shared_alloc_mmap.c
+++ b/ext/opcache/shared_alloc_mmap.c
@@ -49,7 +49,7 @@
static void *find_prefered_mmap_base(size_t requested_size)
{
size_t huge_page_size = 2 * 1024 * 1024;
- uintptr_t last_free_addr = 0;
+ uintptr_t last_free_addr = huge_page_size;
uintptr_t last_candidate = (uintptr_t)MAP_FAILED;
uintptr_t start, end, text_start = 0;
#if defined(__linux__)