From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Subject: Re: [PATCH v3 0/7] File Sealing & memfd_create() Date: Tue, 17 Jun 2014 09:20:46 -0700 Message-ID: References: <1402655819-14325-1-git-send-email-dh.herrmann@gmail.com> <53A01049.6020502@redhat.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01182c3ee1a3f004fc0a8717 Cc: "linux-mm@kvack.org" , Greg KH , Florian Weimer , Hugh Dickins , "linux-kernel@vger.kernel.org" , Lennart Poettering , Andrew Morton , Linux API , Michael Kerrisk , Kay Sievers , John Stultz , Linus Torvalds , Daniel Mack , Ryan Lortie , Linux FS Devel , Tony Battersby To: David Herrmann Return-path: In-Reply-To: Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org --089e01182c3ee1a3f004fc0a8717 Content-Type: text/plain; charset=UTF-8 On Jun 17, 2014 3:01 AM, "David Herrmann" wrote: > > Hi > > On Tue, Jun 17, 2014 at 11:54 AM, Florian Weimer wrote: > > On 06/13/2014 05:33 PM, David Herrmann wrote: > >> > >> On Fri, Jun 13, 2014 at 5:17 PM, Andy Lutomirski > >> wrote: > >>> > >>> Isn't the point of SEAL_SHRINK to allow servers to mmap and read > >>> safely without worrying about SIGBUS? > >> > >> > >> No, I don't think so. > >> The point of SEAL_SHRINK is to prevent a file from shrinking. SIGBUS > >> is an effect, not a cause. It's only a coincidence that "OOM during > >> reads" and "reading beyond file-boundaries" has the same effect: > >> SIGBUS. > >> We only protect against reading beyond file-boundaries due to > >> shrinking. Therefore, OOM-SIGBUS is unrelated to SEAL_SHRINK. > >> > >> Anyone dealing with mmap() _has_ to use mlock() to protect against > >> OOM-SIGBUS. Making SEAL_SHRINK protect against OOM-SIGBUS would be > >> redundant, because you can achieve the same with SEAL_SHRINK+mlock(). > > > > > > I don't think this is what potential users expect because mlock requires > > capabilities which are not available to them. > > > > A couple of weeks ago, sealing was to be applied to anonymous shared memory. > > Has this changed? Why should *reading* it trigger OOM? > > The file might have holes, therefore, you'd have to allocate backing > pages. This might hit a soft-limit and fail. To avoid this, use > fallocate() to allocate pages prior to mmap() or mlock() to make the > kernel lock them in memory. > Can you summarize why holes can't be reliably backed by the zero page? (I realize the kernel could OOM on PTE allocation, but fallocate won't fix that. OTOH MAP_POPULATE should work.) And I don't think I like hole filling being allowed on write-sealed files. Holes are observable these days with SEEK_HOLE and such. Alternatively, we could add a new syscall or madvise option to populate a mapping. --Andy --089e01182c3ee1a3f004fc0a8717 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Jun 17, 2014 3:01 AM, "David Herrmann" <dh.herrmann@gmail.com> wrote= :
>
> Hi
>
> On Tue, Jun 17, 2014 at 11:54 AM, Florian Weimer <fweimer@redhat.com> wrote: > > On 06/13/2014 05:33 PM, David Herrmann wrote:
> >>
> >> On Fri, Jun 13, 2014 at 5:17 PM, Andy Lutomirski <luto@amacapital.net&g= t;
> >> wrote:
> >>>
> >>> Isn't the point of SEAL_SHRINK to allow servers to mm= ap and read
> >>> safely without worrying about SIGBUS?
> >>
> >>
> >> No, I don't think so.
> >> The point of SEAL_SHRINK is to prevent a file from shrinking.= SIGBUS
> >> is an effect, not a cause. It's only a coincidence that &= quot;OOM during
> >> reads" and "reading beyond file-boundaries" ha= s the same effect:
> >> SIGBUS.
> >> We only protect against reading beyond file-boundaries due to=
> >> shrinking. Therefore, OOM-SIGBUS is unrelated to SEAL_SHRINK.=
> >>
> >> Anyone dealing with mmap() _has_ to use mlock() to protect ag= ainst
> >> OOM-SIGBUS. Making SEAL_SHRINK protect against OOM-SIGBUS wou= ld be
> >> redundant, because you can achieve the same with SEAL_SHRINK+= mlock().
> >
> >
> > I don't think this is what potential users expect because mlo= ck requires
> > capabilities which are not available to them.
> >
> > A couple of weeks ago, sealing was to be applied to anonymous sha= red memory.
> > Has this changed? =C2=A0Why should *reading* it trigger OOM?
>
> The file might have holes, therefore, you'd have to allocate backi= ng
> pages. This might hit a soft-limit and fail. To avoid this, use
> fallocate() to allocate pages prior to mmap() or mlock() to make the > kernel lock them in memory.
>

Can you summarize why holes can't be reliably backed by = the zero page?

(I realize the kernel could OOM on PTE allocation, but fallo= cate won't fix that. OTOH MAP_POPULATE should work.)

And I don't think I like hole filling being allowed on w= rite-sealed files.=C2=A0 Holes are observable these days with SEEK_HOLE and= such.

Alternatively, we could add a new syscall or madvise option to= populate a mapping.

--Andy

--089e01182c3ee1a3f004fc0a8717-- -- 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: email@kvack.org