Re: Sealed memfd & no-fault mmap
From: Linus Torvalds
Date: Fri May 28 2021 - 21:04:42 EST
On Fri, May 28, 2021 at 7:07 AM Lin, Ming <minggr@xxxxxxxxx> wrote:
>
> Does something like following draft patch on the right track?
No, I don't think this can work:
> + _dst_pte = pte_mkspecial(pfn_pte(my_zero_pfn(dst_addr),
> + vma->vm_page_prot));
You can't just blindly insert the zero pfn - for a shared write
mapping, that would actually allow writes to the zeropage. That would
be horrible.
So it would have to do all the same things that it does for a page
that is inside the inode size.
I do also dislike how it's a per-inode flag - so it would affect other
mappings of the same shared memory segment too. But considering that
the page would have to be part of the page cache for that shmem inode,
that may be inevitable. But it sure does smell a bit.
Oh, and if we make this kind of magic shmem extension, Hugh Dickins
should be part of the conversation too. Hugh, you probably saw the
original on linux-mm, but I'm adding you explicitly to the
participants here.
.. and if you didn't see the background, here it is
https://lore.kernel.org/linux-mm/vs1Us2sm4qmfvLOqNat0-r16GyfmWzqUzQ4KHbXJwEcjhzeoQ4sBTxx7QXDG9B6zk5AeT7FsNb3CSr94LaKy6Novh1fbbw8D_BBxYsbPLms=@emersion.fr/
for your edification..
Linus