Re: [PATCH 5/5] x86, pti: filter at vma->vm_page_prot population

From: Dave Hansen
Date: Mon Apr 23 2018 - 07:37:33 EST


On 04/20/2018 06:21 PM, Nadav Amit wrote:
>> pgprot_t vm_get_page_prot(unsigned long vm_flags)
>> {
>> - return __pgprot(pgprot_val(protection_map[vm_flags &
>> + pgprot_t ret = __pgprot(pgprot_val(protection_map[vm_flags &
>> (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
>> pgprot_val(arch_vm_get_page_prot(vm_flags)));
>> +
>> + return arch_filter_pgprot(ret);
>> }
>> EXPORT_SYMBOL(vm_get_page_prot);
> Wouldnât it be simpler or at least cleaner to change the protection map if
> NX is not supported? I presume it can be done paging_init() similarly to the
> way other archs (e.g., arm, mips) do.

I thought about it, but doing it there requires getting the _timing_
right. You have to do it before the protection map gets used but after
__supported_pte_mask is totally initialized. This seemed more
straightforward, especially as a bug fix.

What you are talking about might be a good cleanup, though.