lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2dc775e-a8a0-ed08-6c6e-8b98e5bee085@bytedance.com>
Date:   Thu, 26 May 2022 21:23:22 +0800
From:   Qi Zheng <zhengqi.arch@...edance.com>
To:     Pasha Tatashin <pasha.tatashin@...een.com>
Cc:     Miaohe Lin <linmiaohe@...wei.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        David Rientjes <rientjes@...gle.com>,
        linux-mm <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm/page_table_check: fix accessing unmapped ptep



On 2022/5/26 9:11 PM, Pasha Tatashin wrote:
> On Thu, May 26, 2022 at 9:04 AM Qi Zheng <zhengqi.arch@...edance.com> wrote:
>>
>>
>>
>> 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.
> 
> pte_unmap() is needed only with  CONFIG_HIGHPTE. I do not see this
> config for  riskv-32?

My bad, but it's better to call pte_unmap() after the check is done.

> 
> Pasha
> 
>>
>> So:
>>
>> Reviewed-by: Qi Zheng <zhengqi.arch@...edance.com>
>>
>>>
>>> Fixes: 80110bbfbba6 ("mm/page_table_check: check entries at pmd levels")
>>> Signed-off-by: Miaohe Lin <linmiaohe@...wei.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

-- 
Thanks,
Qi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ