Skip to content

Commit 1747f3f

Browse files
committed
ext/opcache/zend_zip_cache: map the ZIP file read-only (and shared)
Using PROT_WRITE and MAP_PRIVATE never made sense. Let's use PROT_READ and MAP_SHARED instead, which disables copy-on-write and may make it easier for the kernel the manage the file mapping.
1 parent 31e51d9 commit 1747f3f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/opcache/zend_zip_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static std::optional<ZendArchive> zend_archive_open(std::string_view path)
222222
return std::nullopt;
223223
}
224224

225-
void *mapping = mmap(nullptr, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
225+
void *mapping = mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
226226
close(fd);
227227
if (mapping == MAP_FAILED)
228228
return std::nullopt;

0 commit comments

Comments
 (0)