Fix asan false positive for mmap

For some reason, mmap regions which are repeatedly munmapped are not correctly
unpoisoned. See https://github.com/google/sanitizers/issues/1705.

Fixes GH-12756
Closes GH-12848
This commit is contained in:
Ilija Tovilo 2023-12-01 16:01:40 +01:00
parent 289073b452
commit 016c3861d7
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A

View File

@ -79,6 +79,9 @@
#include <limits.h>
#include <fcntl.h>
#include <errno.h>
#ifdef __SANITIZE_ADDRESS__
# include <sanitizer/asan_interface.h>
#endif
#ifndef _WIN32
# include <sys/mman.h>
@ -724,6 +727,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
if (zend_mm_use_huge_pages) {
zend_mm_hugepage(ptr, size);
}
#ifdef __SANITIZE_ADDRESS__
ASAN_UNPOISON_MEMORY_REGION(ptr, size);
#endif
return ptr;
} else {
size_t offset;
@ -763,6 +769,9 @@ static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment)
if (zend_mm_use_huge_pages) {
zend_mm_hugepage(ptr, size);
}
# ifdef __SANITIZE_ADDRESS__
ASAN_UNPOISON_MEMORY_REGION(ptr, size);
# endif
#endif
return ptr;
}