lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 17 Jun 2014 14:25:24 -0700
From:	Andy Lutomirski <luto@...capital.net>
To:	Hugh Dickins <hughd@...gle.com>
Cc:	David Herrmann <dh.herrmann@...il.com>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	Greg KH <greg@...ah.com>, Florian Weimer <fweimer@...hat.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Lennart Poettering <lennart@...ttering.net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linux API <linux-api@...r.kernel.org>,
	Michael Kerrisk <mtk.manpages@...il.com>,
	Kay Sievers <kay@...y.org>,
	John Stultz <john.stultz@...aro.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Daniel Mack <zonque@...il.com>, Ryan Lortie <desrt@...rt.ca>,
	Linux FS Devel <linux-fsdevel@...r.kernel.org>,
	Tony Battersby <tonyb@...ernetics.com>
Subject: Re: [PATCH v3 0/7] File Sealing & memfd_create()

On Tue, Jun 17, 2014 at 1:31 PM, Hugh Dickins <hughd@...gle.com> wrote:
> On Tue, 17 Jun 2014, Andy Lutomirski wrote:
>> On Tue, Jun 17, 2014 at 9:51 AM, David Herrmann <dh.herrmann@...il.com> wrote:
>> > On Tue, Jun 17, 2014 at 6:41 PM, Andy Lutomirski <luto@...capital.net> wrote:
>> >> On Tue, Jun 17, 2014 at 9:36 AM, David Herrmann <dh.herrmann@...il.com> wrote:
>> >>> On Tue, Jun 17, 2014 at 6:20 PM, Andy Lutomirski <luto@...capital.net> wrote:
>> >>>> Can you summarize why holes can't be reliably backed by the zero page?
>> >>>
>> >>> To answer this, I will quote Hugh from "PATCH v2 1/3":
>> >>>
>> >>>> We do already use the ZERO_PAGE instead of allocating when it's a
>> >>>> simple read; and on the face of it, we could extend that to mmap
>> >>>> once the file is sealed.  But I am rather afraid to do so - for
>> >>>> many years there was an mmap /dev/zero case which did that, but
>> >>>> it was an easily forgotten case which caught us out at least
>> >>>> once, so I'm reluctant to reintroduce it now for sealing.
>> >>>>
>> >>>> Anyway, I don't expect you to resolve the issue of sealed holes:
>> >>>> that's very much my territory, to give you support on.
>> >>>
>> >>> Holes can be avoided with a simple fallocate(). I don't understand why
>> >>> I should make SEAL_WRITE do the fallocate for the caller. During the
>> >>> discussion of memfd_create() I was told to drop the "size" parameter,
>> >>> because it is redundant. I don't see how this implicit fallocate()
>> >>> does not fall into the same category?
>> >>>
>> >>
>> >> I'm really confused now.
>> >>
>> >> If I SEAL_WRITE a file, and then I mmap it PROT_READ, and then I read
>> >> it, is that a "simple read"?  If so, doesn't that mean that there's no
>> >> problem?
>> >
>> > I assumed Hugh was talking about read(). So no, this is not about
>> > memory-reads on mmap()ed regions.
>> >
>> > Looking at shmem_file_read_iter() I can see a ZERO_PAGE(0) call in
>> > case shmem_getpage_gfp(SGP_READ) tells us there's a hole. I cannot see
>> > anything like that in the mmap_region() and shmem_fault() paths.
>>
>> Would it be easy to fix this just for SEAL_WRITE files?  Hugh?
>>
>> This would make the interface much nicer, IMO.
>
> I do agree with you, Andy.
>
> I agree with David that a fallocate (of the fill-in-holes variety)
> does not have to be prohibited on a sealed file, that detection of
> holes is not an issue with respect to sealing, and that fallocate
> by the recipient could be used to "post-seal" the object to safety.
>
> But it doesn't feel right, and we shall be re-explaining and apologizing
> for it for months to come, until we just fix it.  I suspect David didn't
> want to add a dependency upon me to fix it, and I didn't want to be
> rushed into fixing it (nor is it a job I'd be comfortable to delegate).

I suppose it would be possible to merge memfd_create as is, and then
to fix the zero page thing and make fallocate on a SEAL_WRITEd file be
a no-op.  It would be silly for code to fallocate actual
sealed-with-holes files and allocate fresh pages that are guaranteed
to only ever contain zeros.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists