powerpc: check key protection for user page access
authorRam Pai <linuxram@us.ibm.com>
Fri, 19 Jan 2018 01:50:38 +0000 (17:50 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 20 Jan 2018 11:59:04 +0000 (22:59 +1100)
Make sure that the kernel does not access user pages without
checking their key-protection.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
[mpe: Integrate with upstream version of pte_access_permitted()]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/64/pgtable.h

index 449b797f8b7b5cd037bc3267534daeb6df309488..1c495068bcfa982936de8899480a86469ec06290 100644 (file)
@@ -571,7 +571,14 @@ static inline int pte_present(pte_t pte)
        return !!(pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT));
 }
 
+#ifdef CONFIG_PPC_MEM_KEYS
 extern bool arch_pte_access_permitted(u64 pte, bool write, bool execute);
+#else
+static inline bool arch_pte_access_permitted(u64 pte, bool write, bool execute)
+{
+       return true;
+}
+#endif /* CONFIG_PPC_MEM_KEYS */
 
 #define pte_access_permitted pte_access_permitted
 static inline bool pte_access_permitted(pte_t pte, bool write)
@@ -593,7 +600,8 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
 
        if ((pteval & clear_pte_bits) == clear_pte_bits)
                return false;
-       return true;
+
+       return arch_pte_access_permitted(pte_val(pte), write, 0);
 }
 
 /*