com php-src: Merge branch 'PHP-7.4': ext/opcache/shared_alloc _win32.c
| From: | Christoph Michael Becker | Date: | Tue, 21 May 2019 12:34:55 +0000 |
| Subject: | com php-src: Merge branch 'PHP-7.4': ext/opcache/shared_alloc _win32.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106262@lists.php.net to get a copy of this message | ||
Commit: 68e6c1542e402af133b81518e354b261a5ef6d15
Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 21 May 2019 14:34:55 +0200
Parents: 7dec7a154fd606b5e81952b66490706bab729d93 8ba10b8fbc020dc225d3b19d8f088f1351a3e304
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=68e6c1542e402af133b81518e354b261a5ef6d15
Log:
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix ASLR related invalid opline handler issues
Changed paths:
MM ext/opcache/shared_alloc_win32.c
Diff:
diff --cc ext/opcache/shared_alloc_win32.c
index 76533cc,2755f39..c92eb4b
--- a/ext/opcache/shared_alloc_win32.c
+++ b/ext/opcache/shared_alloc_win32.c
@@@ -181,12 -199,17 +199,17 @@@ static int zend_shared_alloc_reattach(s
return ALLOC_FALLBACK;
}
#endif
- err = ERROR_INVALID_ADDRESS;
- zend_win_error_message(ACCEL_LOG_FATAL, "Base address marks unusable memory region. Please
setup opcache.file_cache and opcache.file_cache_fallback directives for more convenient Opcache
usage", err);
+ if (execute_ex_moved) {
+ err = ERROR_INVALID_ADDRESS;
+ zend_win_error_message(ACCEL_LOG_FATAL, "Opcode handlers are unusable due to ASLR. Please
setup opcache.file_cache and opcache.file_cache_fallback directives for more convenient Opcache
usage", err);
+ } else {
+ err = ERROR_INVALID_ADDRESS;
+ zend_win_error_message(ACCEL_LOG_FATAL, "Base address marks unusable memory region. Please
setup opcache.file_cache and opcache.file_cache_fallback directives for more convenient Opcache
usage", err);
+ }
return ALLOC_FAILURE;
- }
+ }
- mapping_base = MapViewOfFileEx(memfile, FILE_MAP_ALL_ACCESS, 0, 0, 0, wanted_mapping_base);
+ mapping_base = MapViewOfFileEx(memfile, FILE_MAP_ALL_ACCESS|FILE_MAP_EXECUTE, 0, 0, 0,
wanted_mapping_base);
if (mapping_base == NULL) {
err = GetLastError();
@@@ -323,17 -337,9 +346,18 @@@ static int create_segments(size_t reque
*error_in = "MapViewOfFile";
return ALLOC_FAILURE;
} else {
- char *mmap_base_file = get_mmap_base_file();
+ char *mmap_base_file;
+ void *execute_ex_base = (void *)execute_ex;
- FILE *fp = fopen(mmap_base_file, "w");
+ FILE *fp;
+ DWORD old;
+
+ if (!VirtualProtect(mapping_base, requested_size, PAGE_READWRITE, &old)) {
+ err = GetLastError();
+ zend_win_error_message(ACCEL_LOG_FATAL, "VirtualProtect() failed", err);
+ return ALLOC_FAILURE;
+ }
+ mmap_base_file = get_mmap_base_file();
+ fp = fopen(mmap_base_file, "w");
if (!fp) {
err = GetLastError();
zend_shared_alloc_unlock_win32();