Re: [PATCH v3 5/9] mm/mprotect: add MM_CP_PERM_UPGRADE
From: David Hildenbrand (Arm)
Date: Thu Nov 26 2026 - 09:12:41 EST
On 11/15/26 23:03, Carlos López wrote:
> On 11/13/26 7:51 PM, David Hildenbrand (Arm) wrote:
>>> diff --git a/mm/mprotect.c b/mm/mprotect.c
>>> index 84bcfe0281d3..8c0fcd10f5a3 100644
>>> --- a/mm/mprotect.c
>>> +++ b/mm/mprotect.c
>>> @@ -767,6 +767,17 @@ static const struct mm_walk_ops prot_none_walk_ops = {
>>> .walk_lock = PGWALK_WRLOCK,
>>> };
>>>
>>> +static bool vma_flags_is_perm_upgrade(vma_flags_t old_vma_flags,
>>> + vma_flags_t new_vma_flags)
>>
>> Two tab indent.
>
> Will fix
>
>>> +{
>>> + vm_flags_t old = vma_flags_to_legacy(old_vma_flags);
>>> + vm_flags_t new = vma_flags_to_legacy(new_vma_flags);
>>> + /* VM_ACCOUNT does not affect page tables */
>>> + vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC | VM_ACCOUNT;
>>
>> Why is VM_ACCOUNT a permission upgrade? At best it's "no change".
>>
>> What am I missing?
>
> It isn't, this just means to cover the case where mprotect(PROT_READ |
> PROT_WRITE) on a private read-only VMA sets VM_ACCOUNT as well. Without
> this, the change is not detected as an upgrade.
Why is setting VM_ACCOUNT and upgrade for permissions?!
I'm sorry but this is all way to shaky and confusing.
Take a step back and think how to do all of this cleanly without making this
code here unmaintainable :)
--
Cheers,
David