com php-src: Support fixed address mmap without replacement: Zend/zend_alloc.c

From: Date: Fri, 07 Sep 2018 10:10:05 +0000
Subject: com php-src: Support fixed address mmap without replacement: Zend/zend_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103017@lists.php.net to get a copy of this message
Commit: f7b573b4e96f3cf421dc92063b11121da2370e46 Author: David Carlier <devnexen@gmail.com> Wed, 29 Aug 2018 21:04:32 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Fri, 7 Sep 2018 12:10:05 +0200 Parents: 6c376996cf824039776707f7d9f2ff7f0abfd0a1 Branches: PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f7b573b4e96f3cf421dc92063b11121da2370e46 Log: Support fixed address mmap without replacement Reapply changes for Zend fixed mapping but only for FreeBSD. Other BSD might expose some day a similar flag (private for OpenBSD for the moment for example). The Linux's part could be brought back but not before 7.4, at this time, distributions with kernel > 4.17 will be more widely available. Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 11691d8..302f9e7 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -423,11 +423,15 @@ static void *zend_mm_mmap_fixed(void *addr, size_t size) #ifdef _WIN32 return VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #else + int flags = MAP_PRIVATE | MAP_ANON; +#if defined(MAP_EXCL) + flags |= MAP_FIXED | MAP_EXCL; +#endif /* MAP_FIXED leads to discarding of the old mapping, so it can't be used. */ - void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON /*| MAP_POPULATE | MAP_HUGETLB*/, -1, 0); + void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, -1, 0); if (ptr == MAP_FAILED) { -#if ZEND_MM_ERROR +#if ZEND_MM_ERROR && !defined(MAP_EXCL) fprintf(stderr, "\nmmap() failed: [%d] %s\n", errno, strerror(errno)); #endif return NULL;

« previous php.cvs (#103017) next »