Skip to content

Commit 1dc4a57

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 e64bffc commit 1dc4a57

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
@@ -223,7 +223,7 @@ static std::optional<ZendArchive> zend_archive_open(std::string_view path)
223223
return std::nullopt;
224224
}
225225

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

0 commit comments

Comments
 (0)