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] [thread-next>] [day] [month] [year] [list]
Message-ID: <13f149cc-6535-8b50-04de-70437a679826@redhat.com>
Date:   Tue, 9 Aug 2022 22:42:06 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        stable@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Peter Xu <peterx@...hat.com>, Hugh Dickins <hughd@...gle.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Matthew Wilcox <willy@...radead.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        John Hubbard <jhubbard@...dia.com>,
        Jason Gunthorpe <jgg@...dia.com>
Subject: Re: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove
 FOLL_COW

On 09.08.22 22:30, Linus Torvalds wrote:
> On Tue, Aug 9, 2022 at 1:20 PM David Hildenbrand <david@...hat.com> wrote:
>>
>> IIUC VM_MAYSHARE is always set in a MAP_SHARED mapping, but for file
>> mappings we only set VM_SHARED if the file allows for writes
> 
> Heh.
> 
> This is a horrific hack, and probably should go away.
> 
> Yeah, we have that
> 
>                         if (!(file->f_mode & FMODE_WRITE))
>                                 vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
> 
> 
> but I think that's _entirely_ historical.
> 
> Long long ago, in a galaxy far away, we didn't handle shared mmap()
> very well. In fact, we used to not handle it at all.
> 
> But nntpd would use write() to update the spool file, adn them read it
> through a shared mmap.
> 
> And since our mmap() *was* coherent with people doing write() system
> calls, but didn't handle actual dirty shared mmap, what Linux used to
> do was to just say "Oh, you want a read-only shared file mmap? I can
> do that - I'll just downgrade it to a read-only _private_ mapping, and
> it actually ends up with the same semantics".
> 
> And here we are, 30 years later, and it still does that, but it leaves
> the VM_MAYSHARE flag so that /proc/<pid>/maps can show that it's a
> shared mapping.

I was suspecting that this code is full of legacy :)

What would make sense to me is to just have VM_SHARED and make it
correspond to MAP_SHARED, that would at least confuse me less. Once I
have some spare cycles I'll see how easy that might be to achieve.

-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ