foss-for-synopsys-dwc-arc-processors/linux

ARC64/kernel: LTP mprotect04 looping

vineetgarc opened this issue · 3 comments

I enabled LTP for ARC64 and tried executing this on QEMU.
mprotect04 is currently looping - it is working for ARC64 MMUv4 though meaning this is an issue in MMUv6 implementation.

Let me know if you need help in this.

this is a kernel bug !

commit 32734ee (HEAD -> arc64, gh/arc64)
Author: Vineet Gupta vgupta@synopsys.com
Date: Fri Feb 19 14:44:02 2021 -0800

ARCv3: mm: fix pte_modify() not clearing exec related bits: _PAGE_NOTEXEC_U

This showed up a LTP mprotect04 looping on same ProtV fault when trying
to exeute self-modifying code after an mprotect(PROT_EXEC)

pte_modify() needs to clear out existing access/permission bits and set
the ones per mprotect(), while leaving the rest of pte bits intact.

The old code used a mask to "keep" existing bits and supposedly cleared
the rest (since it used PAGE_MASK which cleared everything). However in
ARC64, PAGE_MASK misses the high bits NXU and NXK. So invert the mask
strategy - clear out everything not needed explicitly and rely on
newprot to DTRT.

Implementation wise we are clearing AP.RO and AP.UK so it would seem
that we are making them read-write and user-n-kernel but that is just an
intermediate step as OR with newprot brings in any '1' bits - so __P001
will reinstate AP.RO thus DTRT. This is just an implementation detail
worth noting here.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>