Re: [PATCH v3 5/9] mm/mprotect: add MM_CP_PERM_UPGRADE
From: Carlos López
Date: Sun Nov 15 2026 - 17:04:08 EST
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.
> Also, what you really care about is "no permission downgrade", and "no
> permission upgrade" is not the inverse of that ;)
Right, I'll rename it.