lkml.org 
[lkml]   [2021]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: Sealed memfd & no-fault mmap
From
Date
On 5/28/2021 6:03 PM, Linus Torvalds wrote:
> On Fri, May 28, 2021 at 7:07 AM Lin, Ming <minggr@gmail.com> 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.

I should check the vma is not writable.

diff --git a/mm/shmem.c b/mm/shmem.c
index 856d2d8d4cdf..fa23e38bc692 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1820,7 +1820,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
spinlock_t *ptl;
int ret;

- if (!IS_NOFAULT(inode))
+ if (!IS_NOFAULT(inode) || (vma->vm_flags & VM_WRITE))
return -EINVAL;

_dst_pte = pte_mkspecial(pfn_pte(my_zero_pfn(dst_addr)

\
 
 \ /
  Last update: 2021-05-29 09:32    [W:0.255 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site