Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 22 Sep 2020 09:25:04 -0700 | Subject | Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned |
| |
On Tue, Sep 22, 2020 at 8:56 AM Jason Gunthorpe <jgg@ziepe.ca> wrote: > > I thought MAP_PRIVATE without PROT_WRITE was nonsensical,
MAP_PRIVATE without PROT_WRITE is very common.
It's what happens for every executable mapping, for example.
And no, it's not the same as MAP_SHARED, for a couple of simple reasons. It does end up being similar for all the *normal* cases, but there are various cases where it isn't.
- mprotect() and friends. MAP_PRIVATE is fixed, but it might have been writable in the past, and it might become writable in the future.
- breakpoints and ptrace. This will punch through even a non-writable mapping and force a COW (since that's the whole point: executables are not writable, but to do a SW breakpoint you have to write to the page)
So no, MAP_PRIVATE is not nonsensical without PROT_WRITE, and it's not even remotely unusual.
Linus
| |