Skip to content

Commit ea02682

Browse files
committed
Fix phpGH-13903: ASAN false positive underflow when executing copy()
Closes phpGH-13917.
1 parent e48a5c1 commit ea02682

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug GH-13772 (Invalid execute_data->opline pointers in observer fcall
77
handlers when JIT is enabled). (Bob)
88

9+
- Fibers:
10+
. Fixed bug GH-13903 (ASAN false positive underflow when executing copy()).
11+
(nielsdos)
12+
913
- FPM:
1014
. Fixed bug GH-13563 (Setting bool values via env in FPM config fails).
1115
(Jakub Zelenka)

Zend/zend_fibers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#endif
6363

6464
#ifdef __SANITIZE_ADDRESS__
65+
# include <sanitizer/asan_interface.h>
6566
# include <sanitizer/common_interface_defs.h>
6667
#endif
6768

@@ -257,6 +258,12 @@ static void zend_fiber_stack_free(zend_fiber_stack *stack)
257258

258259
void *pointer = (void *) ((uintptr_t) stack->pointer - ZEND_FIBER_GUARD_PAGES * page_size);
259260

261+
#ifdef __SANITIZE_ADDRESS__
262+
/* If another mmap happens after unmapping, it may trigger the stale stack red zones
263+
* so we have to unpoison it before unmapping. */
264+
ASAN_UNPOISON_MEMORY_REGION(pointer, stack->size + ZEND_FIBER_GUARD_PAGES * page_size);
265+
#endif
266+
260267
#ifdef ZEND_WIN32
261268
VirtualFree(pointer, 0, MEM_RELEASE);
262269
#else

0 commit comments

Comments
 (0)