powerpc: check key protection for user page access
RFC v7 17/25 powerpc: check key protection for user page access
Make sure that the kernel does not access user pages without checking their key-protection.
Signed-off-by Ram Pai <[email protected]>
--- arch/powerpc/include/asm/book3s/64/pgtable.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable.h +14 -0
@@ -479,6 +479,20 @@ static inline void write_uamor(u64 value)#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS extern bool arch_pte_access_permitted (u64 pte,bool write,bool execute); + +#define pte_access_permitted (pte, write) \ + (pte_present(pte) && \ + ((!(write) || pte_write(pte)) && \ + arch_pte_access_permitted(pte_val(pte), !!write, 0))) + +/* +* We store key in pmd for huge tlb pages. So need +* to check for key protection. +*/ +#define pmd_access_permitted (pmd, write) \ + (pmd_present(pmd) && \ + ((!(write) || pmd_write(pmd)) && \ + arch_pte_access_permitted(pmd_val(pmd), !!write, 0)))#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */ #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
Signature · 1 line
1.7.1