mm/page_table_check: fix accessing unmapped ptep

Bugzilla: https://bugzilla.redhat.com/2120352

commit 24c8e27e63224ce832b4723cb60632d3eddb55de
Author: Miaohe Lin <linmiaohe@huawei.com>
Date:   Thu May 26 19:33:50 2022 +0800

    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: 80110bbfbba6 ("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>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
This commit is contained in:
Chris von Recklinghausen 2022-10-12 06:42:11 -04:00
parent 86674c7059
commit 8f87de6e6c
1 changed files with 1 additions and 1 deletions

View File

@ -280,11 +280,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);
}
}