Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

From: Dave Hansen
Date: Mon Mar 05 2018 - 16:26:55 EST


On 03/05/2018 01:14 PM, Khalid Aziz wrote:
> On 03/05/2018 12:22 PM, Dave Hansen wrote:
>> On 02/21/2018 09:15 AM, Khalid Aziz wrote:
>>> +#define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr)
>>> +static inline int sparc_validate_prot(unsigned long prot, unsigned
>>> long addr)
>>> +{
>>> +ÂÂÂ if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM |
>>> PROT_ADI))
>>> +ÂÂÂÂÂÂÂ return 0;
>>> +ÂÂÂ if (prot & PROT_ADI) {
>>> +ÂÂÂÂÂÂÂ if (!adi_capable())
>>> +ÂÂÂÂÂÂÂÂÂÂÂ return 0;
>>> +
>>> +ÂÂÂÂÂÂÂ if (addr) {
>>> +ÂÂÂÂÂÂÂÂÂÂÂ struct vm_area_struct *vma;
>>> +
>>> +ÂÂÂÂÂÂÂÂÂÂÂ vma = find_vma(current->mm, addr);
>>> +ÂÂÂÂÂÂÂÂÂÂÂ if (vma) {
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* ADI can not be enabled on PFN
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * mapped pages
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ */
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return 0;
>>
>> You don't hold mmap_sem here. How can this work?
>>
> Are you suggesting that vma returned by find_vma() could be split or
> merged underneath me if I do not hold mmap_sem and thus make the flag
> check invalid? If so, that is a good point.

Um, yes. You can't walk the vma tree without holding mmap_sem.