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: <dc65a98c-6b82-4ee5-be9f-c073b54833ed@redhat.com>
Date: Tue, 11 Jun 2024 16:48:27 +0200
From: David Hildenbrand <david@...hat.com>
To: Andrew Bresticker <abrestic@...osinc.com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
 Matthew Wilcox <willy@...radead.org>
Subject: Re: [PATCH] mm/memory: Pass head page to do_set_pmd()

On 11.06.24 16:46, David Hildenbrand wrote:
> On 11.06.24 16:18, Andrew Bresticker wrote:
>> The requirement that the head page be passed to do_set_pmd() was added
>> in commit ef37b2ea08ac ("mm/memory: page_add_file_rmap() ->
>> folio_add_file_rmap_[pte|pmd]()") and prevents pmd-mapping in the
>> finish_fault() path if vmf->page is anything but the head page for an
>> otherwise suitable vma and pmd-sized page. Have finish_fault() pass in
>> the head page instead.
>>
>> Fixes: ef37b2ea08ac ("mm/memory: page_add_file_rmap() -> folio_add_file_rmap_[pte|pmd]()")
>> Signed-off-by: Andrew Bresticker <abrestic@...osinc.com>
>> ---
>>    mm/memory.c | 2 +-
>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memory.c b/mm/memory.c
>> index 0f47a533014e..f13b953b507c 100644
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -4764,7 +4764,7 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
>>    
>>    	if (pmd_none(*vmf->pmd)) {
>>    		if (PageTransCompound(page)) {
>> -			ret = do_set_pmd(vmf, page);
>> +			ret = do_set_pmd(vmf, compound_head(page));
>>    			if (ret != VM_FAULT_FALLBACK)
>>    				return ret;
>>    		}
> 
> That certainly makes the "page != &folio->page" check happy.
> 
> It is *likely* incorrect if we would ever have folios > PMD size (which
> we don't have on that path yet).
> 
> I assume that the thp_vma_suitable_order() check would detect any kind
> of "different placement of the folio in virtual address space", where we
> could mess up.
> 
> Question is: should we instead drop the "page != &folio->page" check
> that I added?

To be precise, the something like following:

diff --git a/mm/memory.c b/mm/memory.c
index 5e633c9c27a8b..76f48dc5899cd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4699,8 +4699,9 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
         if (!thp_vma_suitable_order(vma, haddr, PMD_ORDER))
                 return ret;
  
-       if (page != &folio->page || folio_order(folio) != HPAGE_PMD_ORDER)
+       if (folio_order(folio) != HPAGE_PMD_ORDER)
                 return ret;
+       page = &folio->page;
  
         /*
          * Just backoff if any subpage of a THP is corrupted otherwise


-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ