The patch titled Subject: mm/page_table_check: fix accessing unmapped ptep has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-page_table_check-fix-accessing-unmapped-ptep.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_table_check-fix-accessing-unmapped-ptep.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Miaohe Lin <linmiaohe@xxxxxxxxxx> Subject: mm/page_table_check: fix accessing unmapped ptep Date: Thu, 26 May 2022 19:33:50 +0800 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. Link: https://lkml.kernel.org/r/20220526113350.30806-1-linmiaohe@xxxxxxxxxx Fixes: 80110bbfbba6 ("mm/page_table_check: check entries at pmd levels") Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Acked-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/page_table_check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/page_table_check.c~mm-page_table_check-fix-accessing-unmapped-ptep +++ a/mm/page_table_check.c @@ -251,11 +251,11 @@ void __page_table_check_pte_clear_range( 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); } } _ Patches currently in -mm which might be from linmiaohe@xxxxxxxxxx are mm-page_table_check-fix-accessing-unmapped-ptep.patch mm-z3fold-fix-sheduling-while-atomic.patch mm-z3fold-fix-possible-null-pointer-dereferencing.patch mm-z3fold-remove-buggy-use-of-stale-list-for-allocation.patch mm-z3fold-throw-warning-on-failure-of-trylock_page-in-z3fold_alloc.patch revert-mm-z3foldc-allow-__gfp_highmem-in-z3fold_alloc.patch mm-z3fold-put-z3fold-page-back-into-unbuddied-list-when-reclaim-or-migration-fails.patch mm-z3fold-always-clear-page_claimed-under-z3fold-page-lock.patch mm-z3fold-fix-z3fold_reclaim_page-races-with-z3fold_free.patch mm-z3fold-fix-z3fold_page_migrate-races-with-z3fold_map.patch mm-swapfile-unuse_pte-can-map-random-data-if-swap-read-fails.patch mm-swapfile-fix-lost-swap-bits-in-unuse_pte.patch mm-madvise-free-hwpoison-and-swapin-error-entry-in-madvise_free_pte_range.patch mm-shmem-fix-infinite-loop-when-swap-in-shmem-error-at-swapoff-time.patch mm-filter-out-swapin-error-entry-in-shmem-mapping.patch