]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 21 May 2019 12:34:55 +0000 (14:34 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Tue, 21 May 2019 12:34:55 +0000 (14:34 +0200)
* PHP-7.4:
  Fix ASLR related invalid opline handler issues

1  2 
ext/opcache/shared_alloc_win32.c

index 76533cc4f4da8e448091735fab564d7b8b7b8eab,2755f394865bb025b44e5675dc0a34cb2003e7ac..c92eb4bab81ea7f37b3ab6fd50ec2a46dcafdd86
@@@ -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();