diff --git a/NEWS b/NEWS index 84f5597d9780..13b3286c7b67 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,8 @@ PHP NEWS (Ilia Alshanetsky) - Opcache: + . Fixed a crash when the huge page SHM remap discarded mappings outside the + reserved address range. (Piotr Hałas) . Fixed opcache.protect_memory race under ZTS. (realFlowControl) . Fixed bug GH-23288 (Crash on restart when opcache.interned_strings_buffer is overridden in an individual FPM pool). (David Carlier) diff --git a/ext/opcache/shared_alloc_mmap.c b/ext/opcache/shared_alloc_mmap.c index 18c7532478f4..c46b6d8b4aea 100644 --- a/ext/opcache/shared_alloc_mmap.c +++ b/ext/opcache/shared_alloc_mmap.c @@ -245,9 +245,9 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_ /* to got HUGE PAGES in low 32-bit address we have to reserve address space and then remap it using MAP_HUGETLB */ - p = mmap(NULL, requested_size, flags, MAP_SHARED|MAP_ANONYMOUS|MAP_32BIT, fd, 0); + p = mmap(NULL, requested_size + huge_page_size, flags, MAP_SHARED|MAP_ANONYMOUS|MAP_32BIT, fd, 0); if (p != MAP_FAILED) { - munmap(p, requested_size); + munmap(p, requested_size + huge_page_size); p = (void*)(ZEND_MM_ALIGNED_SIZE_EX((ptrdiff_t)p, huge_page_size)); p = mmap(p, requested_size, flags, MAP_SHARED|MAP_ANONYMOUS|MAP_32BIT|MAP_HUGETLB|MAP_FIXED, -1, 0); if (p != MAP_FAILED) {