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: <f2ad010b-b3bf-77c9-2256-701114b5d57e@huawei.com>
Date:   Tue, 2 Aug 2022 14:27:36 +0800
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     Muchun Song <songmuchun@...edance.com>
CC:     Linux-MM <linux-mm@...ck.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Naoya Horiguchi <naoya.horiguchi@...ux.dev>
Subject: Re: [bug report] mm, hwpoison: memory_failure races with
 alloc_fresh_huge_page/free_huge_page

On 2022/8/2 12:07, Muchun Song wrote:
> On Tue, Aug 02, 2022 at 10:00:50AM +0800, Miaohe Lin wrote:
>> Hi all:
>>     When I investigate the mm/memory-failure.c code again, I found there's a possible race window
>> between memory_failure and alloc_fresh_huge_page/free_huge_page. Thank about the below scene:
>>
>> CPU 1							CPU 2
>> alloc_fresh_huge_page -- page refcnt > 0		memory_failure
>>   prep_new_huge_page					  get_huge_page_for_hwpoison
>> 							    !PageHeadHuge -- so 2(not a hugepage) is returned
>>     hugetlb_vmemmap_optimize -- subpages is read-only
>>     set_compound_page_dtor -- PageHuge is true now, but too late!!!
>> 							  TestSetPageHWPoison(p)
>> 							    -- We might write to read-only subpages here!!!
>>
>> Another similar scene:
>>
>> CPU 1							CPU 2
>> free_huge_page -- page refcnt == 0 and not PageHuge	memory_failure
>> 							  get_huge_page_for_hwpoison
>> 							    !PageHeadHuge -- so 2(not a hugepage) is returned
>> 							  TestSetPageHWPoison(p)
>> 							    -- We might write to read-only subpages here!!!
>>   hugetlb_vmemmap_restore -- subpages can be written to now, but too late!!!
>>
> 
> I agree this race is possible, I have proposed this race in thread [1].

Oh, I remember I see the race proposed in [1] but I did not look into that carefully at that time. Sorry.

> But I didn't think more how to solve it.
I hope this thread can find a good solution. :)

> 
> [1] https://lore.kernel.org/linux-mm/20220623235153.2623702-1-naoya.horiguchi@linux.dev/T/#ma094a7cea7df8fd9a77a91551bf39077d89e23bd
> 
>> I think the above scenes are possible. But I can't found a stable solution to fix it. Any suggestions?
>> Or is it not worth to fix it as it's too rare? Or am I miss something?
>>
> 
> Luckily, the system will panic at once, which encountering this race. However,
> we don't see any bug report. If we have an easy way to fix it, I think it is worth.

Agree. But I can't find a easy way to fix it yet.

> Just a quick reply, no suggestion/solutions from me.

Many thanks for your quick reply.

> 
> Thanks.
> 
>> Any response would be appreciated!
>>
>> Thanks!
>>
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ