Skip to content

Commit

Permalink
Fix asan shadow memory and shared_alloc_mmap clash
Browse files Browse the repository at this point in the history
The memory region found by find_prefered_mmap_base may clash with memory regions
reserved by asan for tracking memory. The symptom of this is that mprotect for
JIT fails adding the PROT_EXEC flag to the shared memory region.

Closes GH-12890
  • Loading branch information
iluuu1994 committed Dec 7, 2023
1 parent 299c3ba commit 5390989
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/opcache/shared_alloc_mmap.c
Expand Up @@ -45,7 +45,7 @@
# define MAP_HUGETLB MAP_ALIGNED_SUPER
#endif

#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__))
#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__)) && !defined(__SANITIZE_ADDRESS__)
static void *find_prefered_mmap_base(size_t requested_size)
{
size_t huge_page_size = 2 * 1024 * 1024;
Expand Down Expand Up @@ -169,7 +169,7 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
#ifdef MAP_JIT
flags |= MAP_JIT;
#endif
#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__))
#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__)) && !defined(__SANITIZE_ADDRESS__)
void *hint = find_prefered_mmap_base(requested_size);
if (hint != MAP_FAILED) {
# ifdef MAP_HUGETLB
Expand Down

0 comments on commit 5390989

Please sign in to comment.