diff options
author | Dmitry Stogov <dmitry@zend.com> | 2019-05-14 14:54:30 +0300 |
---|---|---|
committer | Christoph M. Becker <cmb@php.net> | 2019-05-15 08:44:16 +0000 |
commit | 53c1b485741f31a17b24f4db2b39afeb9f4c8aba (patch) | |
tree | 21e524509ae20ad5a63ff704a62f61ac67769c76 | |
parent | 40235e7eefb7057c2d41e3d86dc8f0dfb2e8b3e0 (diff) | |
download | php-git-53c1b485741f31a17b24f4db2b39afeb9f4c8aba.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3php-7.3.6RC1
* PHP-7.2:
Fixed possible crashes, because of inconsistent PCRE cache and opcache SHM reset
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 27 | ||||
-rw-r--r-- | ext/opcache/ZendAccelerator.h | 2 | ||||
-rw-r--r-- | ext/opcache/zend_accelerator_module.c | 14 |
4 files changed, 27 insertions, 20 deletions
@@ -16,6 +16,10 @@ PHP NEWS - JSON: . Fixed bug #77843 (Use after free with json serializer). (Nikita) +- Opcache: + . Fixed possible crashes, because of inconsistent PCRE cache and opcache + SHM reset. (Alexey Kalinin, Dmitry) + - PDO_MySQL: . Fixed bug #77944 (Wrong meta pdo_type for bigint on LLP64). (cmb) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f095429270..a8ea054d43 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -431,7 +431,7 @@ static zend_always_inline zend_string *accel_find_interned_string(zend_string *s } if (!ZCG(counted)) { - if (accel_activate_add() == FAILURE) { + if (!ZCG(accelerator_enabled) || accel_activate_add() == FAILURE) { return str; } ZCG(counted) = 1; @@ -1164,7 +1164,7 @@ char *accel_make_persistent_key(const char *path, size_t path_length, int *key_l cwd_len = ZSTR_LEN(cwd_str); if (ZCG(cwd_check)) { ZCG(cwd_check) = 0; - if ((ZCG(counted) || ZCSG(accelerator_enabled))) { + if (ZCG(accelerator_enabled)) { zend_string *str = accel_find_interned_string(cwd_str); if (!str) { @@ -1204,7 +1204,7 @@ char *accel_make_persistent_key(const char *path, size_t path_length, int *key_l if (ZCG(include_path_check)) { ZCG(include_path_check) = 0; - if ((ZCG(counted) || ZCSG(accelerator_enabled))) { + if (ZCG(accelerator_enabled)) { zend_string *str = accel_find_interned_string(ZCG(include_path)); if (!str) { @@ -1287,7 +1287,7 @@ int zend_accel_invalidate(const char *filename, size_t filename_len, zend_bool f zend_string *realpath; zend_persistent_script *persistent_script; - if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { + if (!ZCG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { return FAILURE; } @@ -1910,7 +1910,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) } else if (file_cache_only) { return file_cache_compile_file(file_handle, type); #endif - } else if ((!ZCG(counted) && !ZCSG(accelerator_enabled)) || + } else if (!ZCG(accelerator_enabled) || (ZCSG(restart_in_progress) && accel_restart_is_active())) { #ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { @@ -2205,12 +2205,11 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl /* zend_resolve_path() replacement for PHP 5.3 and above */ static zend_string* persistent_zend_resolve_path(const char *filename, size_t filename_len) { - if (ZCG(enabled) && accel_startup_ok && + if ( #ifdef HAVE_OPCACHE_FILE_CACHE !file_cache_only && #endif - (ZCG(counted) || ZCSG(accelerator_enabled)) && - !ZCSG(restart_in_progress)) { + ZCG(accelerator_enabled)) { /* check if callback is called from include_once or it's a main request */ if ((!EG(current_execute_data) && @@ -2359,6 +2358,7 @@ static void accel_activate(void) zend_alter_ini_entry_chars(key, "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode"); + ZCG(accelerator_enabled) = 0; return; } } @@ -2416,12 +2416,15 @@ static void accel_activate(void) } accel_restart_leave(); } - } else { + } + if (!ZCG(pcre_reseted)) { reset_pcre = 1; } zend_shared_alloc_unlock(); } + ZCG(accelerator_enabled) = ZCSG(accelerator_enabled); + SHM_PROTECT(); HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -2433,8 +2436,10 @@ static void accel_activate(void) realpath_cache_clean(); accel_reset_pcre_cache(); + ZCG(pcre_reseted) = 0; } else if (reset_pcre) { accel_reset_pcre_cache(); + ZCG(pcre_reseted) = 1; } } @@ -2462,10 +2467,6 @@ static void accel_deactivate(void) zend_string_release_ex(ZCG(cwd), 0); ZCG(cwd) = NULL; } - - if (!ZCG(enabled) || !accel_startup_ok) { - return; - } } static int accelerator_remove_cb(zend_extension *element1, zend_extension *element2) diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 82d666ccdd..fb626fb09a 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -195,6 +195,8 @@ typedef struct _zend_accel_globals { int counted; /* the process uses shared memory */ zend_bool enabled; zend_bool locked; /* thread obtained exclusive lock */ + zend_bool accelerator_enabled; /* accelerator enabled for current request */ + zend_bool pcre_reseted; HashTable bind_hash; /* prototype and zval lookup table */ zend_accel_directives accel_directives; zend_string *cwd; /* current working directory or NULL */ diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 11301a75d2..5b43a55202 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -438,11 +438,11 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) { php_info_print_table_start(); - if (ZCG(enabled) && accel_startup_ok && + if ( #ifdef HAVE_OPCACHE_FILE_CACHE - ((ZCG(counted) || ZCSG(accelerator_enabled)) || file_cache_only) + (ZCG(accelerator_enabled) || file_cache_only) #else - (ZCG(counted) || ZCSG(accelerator_enabled)) + (ZCG(accelerator_enabled)) #endif ) { php_info_print_table_row(2, "Opcode Caching", "Up and Running"); @@ -546,7 +546,7 @@ static int accelerator_get_scripts(zval *return_value) struct timeval exec_time; struct timeval fetch_time; - if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { + if (!ZCG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { return 0; } @@ -608,7 +608,7 @@ static ZEND_FUNCTION(opcache_get_status) array_init(return_value); /* Trivia */ - add_assoc_bool(return_value, "opcache_enabled", ZCG(enabled) && (ZCG(counted) || ZCSG(accelerator_enabled))); + add_assoc_bool(return_value, "opcache_enabled", ZCG(accelerator_enabled)); #ifdef HAVE_OPCACHE_FILE_CACHE if (ZCG(accel_directives).file_cache) { @@ -805,7 +805,7 @@ static ZEND_FUNCTION(opcache_compile_file) return; } - if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled)) { + if (!ZCG(accelerator_enabled)) { zend_error(E_NOTICE, ACCELERATOR_PRODUCT_NAME " seems to be disabled, can't compile file"); RETURN_FALSE; } @@ -844,7 +844,7 @@ static ZEND_FUNCTION(opcache_is_script_cached) RETURN_FALSE; } - if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled)) { + if (!ZCG(accelerator_enabled)) { RETURN_FALSE; } |