aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiaohe Lin <[email protected]>2022-05-26 19:33:50 +0800
committerakpm <[email protected]>2022-05-27 08:55:18 -0700
commit24c8e27e63224ce832b4723cb60632d3eddb55de (patch)
tree7bfdfa301eb22eacbc930dbfc807823350146848
parent3e35142ef99fe6b4fe5d834ad43ee13cca10a2dc (diff)
mm/page_table_check: fix accessing unmapped ptep
ptep is unmapped too early, so ptep could theoretically be accessed while it's unmapped. This might become a problem if/when CONFIG_HIGHPTE becomes available on riscv. Fix it by deferring pte_unmap() until page table checking is done. [[email protected]: account for ptep alteration, per Matthew] Link: https://lkml.kernel.org/r/[email protected] Fixes: 80110bbfbba6 ("mm/page_table_check: check entries at pmd levels") Signed-off-by: Miaohe Lin <[email protected]> Acked-by: Pasha Tatashin <[email protected]> Cc: Qi Zheng <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/page_table_check.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/page_table_check.c b/mm/page_table_check.c
index 2458281bff89..bc55be28807f 100644
--- a/mm/page_table_check.c
+++ b/mm/page_table_check.c
@@ -251,11 +251,11 @@ void __page_table_check_pte_clear_range(struct mm_struct *mm,
pte_t *ptep = pte_offset_map(&pmd, addr);
unsigned long i;
- pte_unmap(ptep);
for (i = 0; i < PTRS_PER_PTE; i++) {
__page_table_check_pte_clear(mm, addr, *ptep);
addr += PAGE_SIZE;
ptep++;
}
+ pte_unmap(ptep - PTRS_PER_PTE);
}
}