lkml.org 
[lkml]   [2022]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] mm/page_table_check: fix accessing unmapped ptep
From


On 2022/5/26 7:33 PM, Miaohe Lin wrote:
> ptep is unmapped too early, so ptep will be accessed while it's unmapped.
> Fix it by deferring pte_unmap() until page table checking is done.

In the beginning, page_table_check only supported x86_64, so there
is no problem. But then the commit 3fee229a8eb9 ("riscv/mm: enable
ARCH_SUPPORTS_PAGE_TABLE_CHECK") added support for riscv-32, it is
indeed a problem in this case.

So:

Reviewed-by: Qi Zheng <zhengqi.arch@bytedance.com>

>
> Fixes: 80110bbfbba6 ("mm/page_table_check: check entries at pmd levels")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> mm/page_table_check.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/page_table_check.c b/mm/page_table_check.c
> index 3692bea2ea2c..971c3129b0e3 100644
> --- a/mm/page_table_check.c
> +++ b/mm/page_table_check.c
> @@ -234,11 +234,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);
> }
> }

--
Thanks,
Qi

\
 
 \ /
  Last update: 2022-05-26 15:06    [W:0.052 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site