Skip to content

Commit

Permalink
#Centipede Protect the shared mmap-ed buffers from forked processes.
Browse files Browse the repository at this point in the history
This is a short-term solution that only works for Linux.

PiperOrigin-RevId: 731036490
  • Loading branch information
xinhaoyuan authored and copybara-github committed Feb 25, 2025
1 parent 313a522 commit 8d4231a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions centipede/shared_memory_blob_sequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ void SharedMemoryBlobSequence::MmapData() {
data_ = static_cast<uint8_t *>(
mmap(nullptr, size_, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
ErrorOnFailure(data_ == MAP_FAILED, "mmap() failed");
#ifndef __APPLE__
// TODO: b/385774476 - this is a temporary and Linux-only solution to protect
// the mmap-ed region from forked processes.
ErrorOnFailure(madvise(data_, size_, MADV_DONTFORK), "madvise() failed");
#endif
}

SharedMemoryBlobSequence::~SharedMemoryBlobSequence() {
Expand Down

0 comments on commit 8d4231a

Please sign in to comment.