Skip to content

Commit 19befb1

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #74663 (Segfault with opcache.memory_protect and validate_timestamp)
2 parents 1838f96 + 60912e6 commit 19befb1

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,17 @@ int validate_timestamp_and_record(zend_persistent_script *persistent_script, zen
960960
}
961961
}
962962

963+
int validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
964+
{
965+
int ret;
966+
967+
SHM_UNPROTECT();
968+
ret = validate_timestamp_and_record(persistent_script, file_handle);
969+
SHM_PROTECT();
970+
971+
return ret;
972+
}
973+
963974
/* Instead of resolving full real path name each time we need to identify file,
964975
* we create a key that consist from requested file name, current working
965976
* directory, current include_path, etc */

ext/opcache/ZendAccelerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void zend_accel_schedule_restart(zend_accel_restart_reason reason);
310310
void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason);
311311
accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_t *size);
312312
int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
313+
int validate_timestamp_and_record_ex(zend_persistent_script *persistent_script, zend_file_handle *file_handle);
313314
int zend_accel_invalidate(const char *filename, int filename_len, zend_bool force);
314315
int accelerator_shm_read_lock(void);
315316
void accelerator_shm_read_unlock(void);

ext/opcache/tests/bug74663.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #74663 (Segfault with opcache.memory_protect and validate_timestamp)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.enable_file_override=1
8+
opcache.validate_timestamps=1
9+
opcache.revalidate_freq=0
10+
opcache.protect_memory=1
11+
--SKIPIF--
12+
<?php require_once('skipif.inc'); ?>
13+
--FILE--
14+
<?php
15+
$file = __DIR__ . "/bug74663.inc";
16+
file_put_contents($file, "");
17+
include $file;
18+
19+
var_dump(is_file($file));
20+
?>
21+
--CLEAN--
22+
<?php
23+
unlink(__DIR__ . "/bug74663.inc");
24+
--EXPECT--
25+
bool(true)

ext/opcache/zend_accelerator_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int filename_is_in_cache(zend_string *filename)
342342
handle.type = ZEND_HANDLE_FILENAME;
343343

344344
if (ZCG(accel_directives).validate_timestamps) {
345-
return validate_timestamp_and_record(persistent_script, &handle) == SUCCESS;
345+
return validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS;
346346
}
347347

348348
return 1;

0 commit comments

Comments
 (0)