aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2013-01-09 06:08:10 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2013-01-10 05:43:44 -0500
commit02522463c84748b3b8ad770f9424bcfa70a5b4c4 (patch)
tree5fc357a4979da3d355735215a01900b3f2e2994c /arch
parentbdba0051ebcb3c6372f9cc0b2524c47cc6ce46fd (diff)
arm64: mm: only wrprotect clean ptes if they are present
Marking non-present ptes as read-only can corrupt file ptes, breaking things like swap and file mappings. This patch ensures that we only manipulate user pte bits when the pte is marked present. Cc: <stable@vger.kernel.org> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/include/asm/pgtable.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 64b133949502..7adf4142a85c 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -132,9 +132,8 @@ extern struct page *empty_zero_page;
132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY)) 132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY))
133#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) 133#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
134 134
135#define pte_present_exec_user(pte) \ 135#define pte_present_user(pte) \
136 ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == \ 136 ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
137 (PTE_VALID | PTE_USER))
138 137
139#define PTE_BIT_FUNC(fn,op) \ 138#define PTE_BIT_FUNC(fn,op) \
140static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; } 139static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
@@ -157,10 +156,13 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr);
157static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 156static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
158 pte_t *ptep, pte_t pte) 157 pte_t *ptep, pte_t pte)
159{ 158{
160 if (pte_present_exec_user(pte)) 159 if (pte_present_user(pte)) {
161 __sync_icache_dcache(pte, addr); 160 if (pte_exec(pte))
162 if (!pte_dirty(pte)) 161 __sync_icache_dcache(pte, addr);
163 pte = pte_wrprotect(pte); 162 if (!pte_dirty(pte))
163 pte = pte_wrprotect(pte);
164 }
165
164 set_pte(ptep, pte); 166 set_pte(ptep, pte);
165} 167}
166 168