Skip to content

Fix GH-13903: ASAN false positive underflow when executing copy() #13917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#endif

#ifdef __SANITIZE_ADDRESS__
# include <sanitizer/asan_interface.h>
# include <sanitizer/common_interface_defs.h>
#endif

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

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

#ifdef __SANITIZE_ADDRESS__
/* If another mmap happens after unmapping, it may trigger the stale stack red zones
* so we have to unpoison it before unmapping. */
ASAN_UNPOISON_MEMORY_REGION(pointer, stack->size + ZEND_FIBER_GUARD_PAGES * page_size);
#endif

#ifdef ZEND_WIN32
VirtualFree(pointer, 0, MEM_RELEASE);
#else
Expand Down