~quark/QuarkContainer

Re: mprotect syscall no longer writes to PTE flags?

Details
Message ID
<D1A4MXEPARBT.23C4HRPOI86W0@mailbox.org>
DKIM signature
pass
Download raw message
On Tue May 14, 2024 at 4:00 PM CEST, Yulin Sun wrote:
> Yes. When mprotect doing RO-->RW change, if we change pagetable flags, the CoW
> process will be disabled. For example, for private mapping of readonly file,
> when change to RW pagetable flags, the system will try to write the file and
> system will crash.
>

I intuitively think ... MProtect operation on a RO page should be treated as a
COW event as well, i.e. allocate/copy the child page before applying PTE flag
changes to either parent or child.

Also, if a process is requesting RO->RW, it  would very likely do write to that
memory afterwards, and COW would be triggered anyways. Why not proactively do
the COW upon RO->RW sys_mprotect calls?

> Looks like there is still issue, when mprotect doing RW -> RO or less
> permission, what's the right behavior?

If we simply stop changing PTE flags on sys_mprotect calls, then the mprotect
would be effectless. Because wrting on the "RO" pages will not trigger PFs.

cheers,
wth
Reply to thread Export thread (mbox)