Reputation: 129
I'm trying to understand how does mmap works in relation to shared memory. Does the MAP_SHARED flag disables Copy-on-Write? Because if so, any malicious process could alter shared libraries. Thanks.
Upvotes: 0
Views: 512
Reputation: 241
Yes, when the MAP_SHARED flag is used, there should be no copy on write -- if you write to the mapped location, all changes to the mapping will be visible to other processes using the mapping, and eventually the backing file will be updated as well. That being said, I believe shared libraries are usually mmap-ed by the dynamic loader with MAP_PRIVATE (which makes updates using a copy on write page), as noted in another answer here.
Upvotes: 1