Skip to content

Commit f2c7e35

Browse files
ruscurmpe
authored andcommitted
powerpc/mm: Fix false detection of read faults
To support detection of read faults with Radix execute-only memory, the vma_is_accessible() check in access_error() (which checks for PROT_NONE) was replaced with a check to see if VM_READ was missing, and if so, returns true to assert the fault was caused by a bad read. This is incorrect, as it ignores that both VM_WRITE and VM_EXEC imply read on powerpc, as defined in protection_map[]. This causes mappings containing VM_WRITE or VM_EXEC without VM_READ to misreport the cause of page faults, since the MMU is still allowing reads. Correct this by restoring the original vma_is_accessible() check for PROT_NONE mappings, and adding a separate check for Radix PROT_EXEC-only mappings. Fixes: 395cac7 ("powerpc/mm: Support execute-only memory on the Radix MMU") Reported-by: Michal Suchánek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Benjamin Gray <[email protected]> Signed-off-by: Russell Currey <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 6175b70 commit f2c7e35

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arch/powerpc/mm/fault.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,16 @@ static bool access_error(bool is_write, bool is_exec, struct vm_area_struct *vma
271271
}
272272

273273
/*
274-
* Check for a read fault. This could be caused by a read on an
275-
* inaccessible page (i.e. PROT_NONE), or a Radix MMU execute-only page.
274+
* VM_READ, VM_WRITE and VM_EXEC all imply read permissions, as
275+
* defined in protection_map[]. Read faults can only be caused by
276+
* a PROT_NONE mapping, or with a PROT_EXEC-only mapping on Radix.
276277
*/
277-
if (unlikely(!(vma->vm_flags & VM_READ)))
278+
if (unlikely(!vma_is_accessible(vma)))
278279
return true;
280+
281+
if (unlikely(radix_enabled() && ((vma->vm_flags & VM_ACCESS_FLAGS) == VM_EXEC)))
282+
return true;
283+
279284
/*
280285
* We should ideally do the vma pkey access check here. But in the
281286
* fault path, handle_mm_fault() also does the same check. To avoid

0 commit comments

Comments
 (0)