Skip to content

Commit 1ee5e87

Browse files
author
Russell King
committed
ARM: fix get_user_pages_fast
Ensure that get_user_pages_fast() is not able to access memory which has been mapped with PROT_NONE. Reported-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent b9dd05c commit 1ee5e87

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/arm/include/asm/pgtable.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
232232
#define pte_valid_user(pte) \
233233
(pte_valid(pte) && pte_isset((pte), L_PTE_USER) && pte_young(pte))
234234

235+
static inline bool pte_access_permitted(pte_t pte, bool write)
236+
{
237+
pteval_t mask = L_PTE_PRESENT | L_PTE_USER;
238+
pteval_t needed = mask;
239+
240+
if (write)
241+
mask |= L_PTE_RDONLY;
242+
243+
return (pte_val(pte) & mask) == needed;
244+
}
245+
#define pte_access_permitted pte_access_permitted
246+
235247
#if __LINUX_ARM_ARCH__ < 6
236248
static inline void __sync_icache_dcache(pte_t pteval)
237249
{

0 commit comments

Comments
 (0)