Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE
From: Florian Weimer
Date: Thu Aug 12 2021 - 14:16:10 EST
* Eric W. Biederman:
> Given that MAP_PRIVATE for shared libraries is our strategy for handling
> writes to shared libraries perhaps we just need to use MAP_POPULATE or a
> new related flag (perhaps MAP_PRIVATE_NOW) that just makes certain that
> everything mapped from the executable is guaranteed to be visible from
> the time of the mmap, and any changes from the filesystem side after
> that are guaranteed to cause a copy on write.
I think this is called MAP_COPY:
<https://www.gnu.org/software/hurd/glibc/mmap.html>
If we could get that functionality, we would certainly use it in the
glibc dynamic loader. And it's not just dynamic loaders that would
benefit.
But I assume there are some rather thorny issues around semantics. If
the changed areas of the file are in the page cache already, everything
is okay. But if parts of the file are changed or discarded that are
not, they would have to be read in first, which is rather awkward.
That's why I suggested the signal for all future accesses. It seems
more tractable and addresses the largest issue (the difficulty of
figuring out why some processes crash occasionally).
Thanks,
Florian