Skip to content

Commit

Permalink
Add READ access of mmap() in docker env
Browse files Browse the repository at this point in the history
In docker multi-architecture environment, calling the
mmap() with only PROT_WRITE would fail the following
write(). Adding PROT_READ access would solve the issue.
The logic there only needs WRITE access, however, it
should be fine to assign READ access too. Actually,
PROT_WRITE is offen implementated as PROT_READ|PROT_WRITE.

fix: #7135.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

Closes #10761.

PiperOrigin-RevId: 295190291
  • Loading branch information
yhwang authored and copybara-github committed Feb 14, 2020
1 parent 4dfe7b2 commit 5370e40
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion third_party/ijar/mapped_file_unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ MappedOutputFile::MappedOutputFile(const char* name, size_t estimated_size)
size_t mmap_length =
std::min(static_cast<size_t>(estimated_size + sysconf(_SC_PAGESIZE)),
std::numeric_limits<size_t>::max());
void* mapped = mmap(NULL, mmap_length, PROT_WRITE, MAP_SHARED, fd, 0);
void* mapped =
mmap(NULL, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mapped == MAP_FAILED) {
snprintf(errmsg, MAX_ERROR, "mmap(): %s", strerror(errno));
errmsg_ = errmsg;
Expand Down

0 comments on commit 5370e40

Please sign in to comment.