linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	aarcange@redhat.com, "Hugh Dickins" <hughd@google.com>,
	nyc@holomorphy.com
Subject: Re: [PATCH 4/6] hugetlbfs: implement memfd sealing
Date: Fri, 3 Nov 2017 10:56:11 -0700	[thread overview]
Message-ID: <15b59408-7c4d-bbdb-7573-5789faa05e6c@oracle.com> (raw)
In-Reply-To: <CANq1E4Tb5zuMxwuHFjLBJ==H219ucmO2=V7iM+K7AAuY-iinoQ@mail.gmail.com>

On 11/03/2017 10:41 AM, David Herrmann wrote:
> Hi
> 
> On Fri, Nov 3, 2017 at 6:12 PM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
>> On 11/03/2017 10:03 AM, David Herrmann wrote:
>>> Hi
>>>
>>> On Tue, Oct 31, 2017 at 7:40 PM, Marc-André Lureau
>>> <marcandre.lureau@redhat.com> wrote:
>>>> Implements memfd sealing, similar to shmem:
>>>> - WRITE: deny fallocate(PUNCH_HOLE). mmap() write is denied in
>>>>   memfd_add_seals(). write() doesn't exist for hugetlbfs.
>>>> - SHRINK: added similar check as shmem_setattr()
>>>> - GROW: added similar check as shmem_setattr() & shmem_fallocate()
>>>>
>>>> Except write() operation that doesn't exist with hugetlbfs, that
>>>> should make sealing as close as it can be to shmem support.
>>>
>>> SEAL, SHRINK, and GROW look fine to me.
>>>
>>> Regarding WRITE
>>
>> The commit message may not be clear.  However, hugetlbfs does not support
>> the write system call (or aio).  The only way to modify contents of a
>> hugetlbfs file is via mmap or hole punch/truncate.  So, we do not really
>> need to worry about those special (a)io cases for hugetlbfs.
> 
> This is not about the write(2) syscall. Please consider this scenario
> about shmem:
> 
> You create a memfd via memfd_create() and map it writable. You now
> call another kernel syscall that takes as input _any mapped page
> range_. You pass your mapped memfd-addresses to it. Those syscalls
> tend to use get_user_pages() to pin arbitrary user-mapped pages, as
> such this also affects shmem. In this case, those pages might stay
> mapped even if you munmap() your memfd!
> 
> One example of this is using AIO-read() on any other file that
> supports it, passing your mapped memfd as buffer to _read into_. The
> operations supported on the memfd are irrelevant here.
> The selftests contain a FUSE-based test for this, since FUSE allows
> user-space to GUP pages for an arbitrary amount of time.
> 
> The original fix for this is:
> 
>     commit 05f65b5c70909ef686f865f0a85406d74d75f70f
>     Author: David Herrmann <dh.herrmann@gmail.com>
>     Date:   Fri Aug 8 14:25:36 2014 -0700
> 
>         shm: wait for pins to be released when sealing
> 
> Please have a look at this. Your patches use shmem_add_seals() almost
> unchanged, and as such you call into shmem_wait_for_pins() on
> hugetlbfs. I would really like to see an explicit ACK that this works
> on hugetlbfs.

Thanks for the explanation.  I missed that in your first reply.  I'll
look into this for hugetlbfs.

-- 
Mike Kravetz

> 
> Thanks
> David
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=ilto:"dont@kvack.org"> email@kvack.org </a>
> 

  reply	other threads:[~2017-11-03 17:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 18:40 [PATCH 0/6] memfd: add sealing to hugetlb-backed memory Marc-André Lureau
2017-10-31 18:40 ` [PATCH 1/6] shmem: unexport shmem_add_seals()/shmem_get_seals() Marc-André Lureau
2017-11-01 22:50   ` Mike Kravetz
2017-10-31 18:40 ` [PATCH 2/6] shmem: rename functions that are memfd-related Marc-André Lureau
2017-11-01 23:01   ` Mike Kravetz
2017-11-03 16:02     ` Marc-André Lureau
2017-11-03 16:22       ` Mike Kravetz
2017-11-03 16:36         ` Marc-André Lureau
2017-11-03 18:07           ` Mike Kravetz
2017-10-31 18:40 ` [PATCH 3/6] hugetlb: expose hugetlbfs_inode_info in header Marc-André Lureau
2017-11-01 23:20   ` Mike Kravetz
2017-11-03 16:14     ` Marc-André Lureau
2017-11-03 16:23       ` Mike Kravetz
2017-10-31 18:40 ` [PATCH 4/6] hugetlbfs: implement memfd sealing Marc-André Lureau
2017-11-01 23:44   ` Mike Kravetz
2017-11-03 17:03   ` David Herrmann
2017-11-03 17:12     ` Mike Kravetz
2017-11-03 17:41       ` David Herrmann
2017-11-03 17:56         ` Mike Kravetz [this message]
2017-11-03 23:31           ` Mike Kravetz
2017-11-05 12:07             ` David Herrmann
2017-10-31 18:40 ` [PATCH 5/6] shmem: add sealing support to hugetlb-backed memfd Marc-André Lureau
2017-11-02  0:18   ` Mike Kravetz
2017-11-03 16:13     ` Marc-André Lureau
2017-10-31 18:40 ` [PATCH 6/6] memfd-tests: test hugetlbfs sealing Marc-André Lureau
2017-11-03 23:59   ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15b59408-7c4d-bbdb-7573-5789faa05e6c@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=dh.herrmann@gmail.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=nyc@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).