1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix GH-20483: ASAN stack overflow with small fiber.stack_size INI value.
This commit is contained in:
David Carlier
2025-11-15 17:21:39 +00:00
3 changed files with 26 additions and 1 deletions

4
NEWS
View File

@@ -16,6 +16,10 @@ PHP NEWS
with a given skeleton, locale, collapse type and identity fallback.
(BogdanUngureanu)
- Fibers:
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
small value). (David Carlier)
- Opcache:
. Fixed bug GH-20051 (apache2 shutdowns when restart is requested during
preloading). (Arnaud, welcomycozyhom)

View File

@@ -0,0 +1,16 @@
--TEST--
GH-20483 (ASAN stack overflow with small fiber.stack_size INI value)
--INI--
fiber.stack_size=1024
--FILE--
<?php
$callback = function () {};
$fiber = new Fiber($callback);
try {
$fiber->start();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
Fiber stack size is too small, it needs to be at least %d bytes

View File

@@ -207,7 +207,12 @@ static zend_fiber_stack *zend_fiber_stack_allocate(size_t size)
{
void *pointer;
const size_t page_size = zend_fiber_get_page_size();
const size_t minimum_stack_size = page_size + ZEND_FIBER_GUARD_PAGES * page_size;
const size_t minimum_stack_size = page_size + ZEND_FIBER_GUARD_PAGES * page_size
#ifdef __SANITIZE_ADDRESS__
// necessary correction due to ASAN redzones
* 6
#endif
;
if (size < minimum_stack_size) {
zend_throw_exception_ex(NULL, 0, "Fiber stack size is too small, it needs to be at least %zu bytes", minimum_stack_size);