lkml.org 
[lkml]   [2022]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW
From
On 09.08.22 22:14, Linus Torvalds wrote:
> On Tue, Aug 9, 2022 at 1:07 PM David Hildenbrand <david@redhat.com> wrote:
>>
>>> /* But FOLL_FORCE has no effect on shared mappings */
>>> if (vma->vm_flags & MAP_SHARED)
>>> return false;
>>
>> I'd actually rather check for MAP_MAYSHARE here, which is even stronger.
>> Thoughts?
>
> Hmm. Adding the test for both is basically free (all those vm_flags
> checks end up being a bit mask and compare), so no objections.
>
> For some reason I though VM_SHARED and VM_MAYSHARE end up always being
> the same bits, and it was a mistake to make them two bits in the first
> place (unlike the read/write/exec bits that can are about mprotect),
>
> But as there are two bits, I'm sure somebody ends up touching one and
> not the other.
>
> So yeah, I don't see any downside to just checking both bits.
>
> [ That said, is_cow_mapping() only checks VM_SHARED, so if they are
> ever different, that's a potential source of confusion ]

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 (and we can
set VM_MAYWRITE or even VM_WRITE). [don't ask me why, it's a steady
source of confusion]

That's why is_cow_mapping() works even due to the weird MAP_SHARED vs.
VM_MAYSHARE logic.


I'd actually only check for VM_MAYSHARE here, which implies MAP_SHARED.
If someone would ever mess that up, I guess we'd be in bigger trouble.

But whatever you prefer.

--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2022-08-09 22:22    [W:0.128 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site