Skip to content

Commit 0ffe1ae

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: mm: implement pgprot_nx
commit cca98e9 ("mm: enforce that vmap can't map pages executable") enforces the W^X protection by not allowing remapping existing pages as executable. Add riscv bits so that riscv can benefit the same protection. Signed-off-by: Jisheng Zhang <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 7115ff4 commit 0ffe1ae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
593593
return ptep_test_and_clear_young(vma, address, ptep);
594594
}
595595

596+
#define pgprot_nx pgprot_nx
597+
static inline pgprot_t pgprot_nx(pgprot_t _prot)
598+
{
599+
return __pgprot(pgprot_val(_prot) & ~_PAGE_EXEC);
600+
}
601+
596602
#define pgprot_noncached pgprot_noncached
597603
static inline pgprot_t pgprot_noncached(pgprot_t _prot)
598604
{

0 commit comments

Comments
 (0)