Skip to content

Commit 016c386

Browse files
committed
Fix asan false positive for mmap
For some reason, mmap regions which are repeatedly munmapped are not correctly unpoisoned. See google/sanitizers#1705. Fixes GH-12756 Closes GH-12848
1 parent 289073b commit 016c386

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Zend/zend_alloc.c

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
#include <limits.h>
8080
#include <fcntl.h>
8181
#include <errno.h>
82+
#ifdef __SANITIZE_ADDRESS__
83+
# include <sanitizer/asan_interface.h>
84+
#endif
8285

8386
#ifndef _WIN32
8487
# include <sys/mman.h>
@@ -724,6 +727,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
724727
if (zend_mm_use_huge_pages) {
725728
zend_mm_hugepage(ptr, size);
726729
}
730+
#ifdef __SANITIZE_ADDRESS__
731+
ASAN_UNPOISON_MEMORY_REGION(ptr, size);
732+
#endif
727733
return ptr;
728734
} else {
729735
size_t offset;
@@ -763,6 +769,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
763769
if (zend_mm_use_huge_pages) {
764770
zend_mm_hugepage(ptr, size);
765771
}
772+
# ifdef __SANITIZE_ADDRESS__
773+
ASAN_UNPOISON_MEMORY_REGION(ptr, size);
774+
# endif
766775
#endif
767776
return ptr;
768777
}

0 commit comments

Comments
 (0)