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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8ff9d672-88ba-4be0-8666-b63917600d73@oracle.com>
Date: Mon, 30 Sep 2024 12:06:07 +0100
From: Joao Martins <joao.m.martins@...cle.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
        "Kun(llfl)" <llfl@...ux.alibaba.com>
Cc: linux-kernel@...r.kernel.org, Dan Williams <dan.j.williams@...el.com>
Subject: Re: [PATCH 1/1] device-dax: Correct pgoff align in dax_set_mapping()

On 27/09/2024 18:46, Andrew Morton wrote:
> (cc's added)
> 
> On Fri, 27 Sep 2024 15:45:09 +0800 "Kun(llfl)" <llfl@...ux.alibaba.com> wrote:
> 
>> pgoff should be aligned using ALIGN_DOWN() instead of ALIGN(). Otherwise,
>> vmf->address not aligned to fault_size will be aligned to the next
>> alignment, that can result in memory failure getting the wrong address.
>>
>> Fixes: b9b5777f09be ("device-dax: use ALIGN() for determining pgoff")
> 
> That's quite an old change.  Can you suggest why it took this long to
> be discovered?  What is your userspace doing to trigger this?
> 
Likely we never reproduce in production because we always pin device-dax regions
in the region align they provide (Qemu does similarly with prealloc in
hugetlb/file backed memory). I think this bug requires that we touch *unpinned*
device-dax regions unaligned to the device-dax selected alignment (page size
i.e. 4K/2M/1G)

>> Signed-off-by: Kun(llfl) <llfl@...ux.alibaba.com>
>> Tested-by: JianXiong Zhao <zhaojianxiong.zjx@...baba-inc.com>

Thanks a lot for the catch and sorry for the pain that it may have caused you:

	Reviewed-by: Joao Martins <joao.m.martins@...cle.com>

>> ---
>>  drivers/dax/device.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dax/device.c b/drivers/dax/device.c
>> index 9c1a729cd77e..6d74e62bbee0 100644
>> --- a/drivers/dax/device.c
>> +++ b/drivers/dax/device.c
>> @@ -86,7 +86,7 @@ static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn,
>>  		nr_pages = 1;
>>  
>>  	pgoff = linear_page_index(vmf->vma,
>> -			ALIGN(vmf->address, fault_size));
>> +			ALIGN_DOWN(vmf->address, fault_size));
>>  
>>  	for (i = 0; i < nr_pages; i++) {
>>  		struct page *page = pfn_to_page(pfn_t_to_pfn(pfn) + i);
>> -- 
>> 2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ