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

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  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:20 +00:00
3 changed files with 26 additions and 1 deletions

4
NEWS
View File

@@ -14,6 +14,10 @@ PHP NEWS
in $selectors to be lowercase). (ndossche)
. Fix missing NUL byte check on C14NFile(). (ndossche)
- Fibers:
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
small value). (David Carlier)
- Opcache:
. Fixed bug GH-20329 (opcache.file_cache broken with full interned string
buffer). (Arnaud)

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);