Re: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW
From: David Hildenbrand
Date: Tue Aug 09 2022 - 15:08:29 EST
On 09.08.22 20:27, Linus Torvalds wrote:
> I'm still reading through this, but
>
> STOP DOING THIS
>
> On Mon, Aug 8, 2022 at 12:32 AM David Hildenbrand <david@xxxxxxxxxx> wrote:
>>
>> + VM_BUG_ON(!is_cow_mapping(vma->vm_flags));
>
> Using BUG_ON() for debugging is simply not ok.
>
> And saying "but it's just a VM_BUG_ON()" does not change *anything*.
> At least Fedora enables that unconditionally for normal people, it is
> not some kind of "only VM people do this".
>
> Really. BUG_ON() IS NOT FOR DEBUGGING.
I totally agree with BUG_ON ... but if I get talked to in all-caps on a
Thursday evening and feel like I just touched the forbidden fruit, I
have to ask for details about VM_BUG_ON nowadays.
VM_BUG_ON is only active with CONFIG_DEBUG_VM. ... which indicated some
kind of debugging at least to me. I *know* that Fedora enables it and I
*know* that this will make Fedora crash.
I know why Fedora enables this debug option, but it somewhat destorys
the whole purpose of VM_BUG_ON kind of nowadays?
For this case, this condition will never trigger and I consider it much
more a hint to the reader that we can rest assured that this condition
holds. And on production systems, it will get optimized out.
Should we forbid any new usage of VM_BUG_ON just like we mostly do with
BUG_ON?
>
> Stop it. Now.
>
> If you have a condition that must not happen, you either write that
> condition into the code, or - if you are convinced it cannot happen -
> you make it a WARN_ON_ONCE() so that people can report it to you.
I can just turn that into a WARN_ON_ONCE() or even a VM_WARN_ON_ONCE().
--
Thanks,
David / dhildenb