Skip to content

Commit 24c8e27

Browse files
MiaoheLinakpm00
authored andcommitted
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. [akpm@linux-foundation.org: account for ptep alteration, per Matthew] Link: https://lkml.kernel.org/r/20220526113350.30806-1-linmiaohe@huawei.com Fixes: 80110bb ("mm/page_table_check: check entries at pmd levels") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Acked-by: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Qi Zheng <zhengqi.arch@bytedance.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 3e35142 commit 24c8e27

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/page_table_check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ void __page_table_check_pte_clear_range(struct mm_struct *mm,
251251
pte_t *ptep = pte_offset_map(&pmd, addr);
252252
unsigned long i;
253253

254-
pte_unmap(ptep);
255254
for (i = 0; i < PTRS_PER_PTE; i++) {
256255
__page_table_check_pte_clear(mm, addr, *ptep);
257256
addr += PAGE_SIZE;
258257
ptep++;
259258
}
259+
pte_unmap(ptep - PTRS_PER_PTE);
260260
}
261261
}

0 commit comments

Comments
 (0)