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]
Date:	Mon, 02 Feb 2015 15:02:28 +0100
From:	Jiri Slaby <jslaby@...e.cz>
To:	Tim Chen <tim.c.chen@...ux.intel.com>,
	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
CC:	"H. Peter Anvin" <hpa@...or.com>,
	Akinobu Mita <akinobu.mita@...il.com>,
	Mathias Nyman <mathias.nyman@...ux.intel.com>,
	Andi Kleen <andi@...stfloor.org>, Ingo Molnar <mingo@...e.hu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	linux-kernel@...r.kernel.org, x86@...nel.org,
	linux-usb@...r.kernel.org, stable <stable@...r.kernel.org>
Subject: Re: [PATCH] pci-dma: Fix x86 dma_alloc_coherent to fully clear all
 pages returned

On 01/30/2015, 10:54 PM, Tim Chen wrote:
> On Sat, 2015-01-31 at 00:03 +0300, Sergei Shtylyov wrote:
>> On 01/30/2015 10:54 PM, Tim Chen wrote:
> 
>>>
>>>   		return NULL;
>>>   	}
>>> +	/* round up to full page size */
>>> +	size = (((size-1) >> PAGE_SHIFT) + 1) * PAGE_SIZE;
>>
>>     This is quite suboptimal formula, we can do without shifts and 
>> multiplications (hopefully, still converted to shifts by gcc):
>>
>> 	size = (size + ~PAGE_MASK) & PAGE_MASK;
> 
> Agree.  I've updated patch below
> 
> Thanks.
> 
> Tim
> 
> --->8---
> 
> From: Tim Chen <tim.c.chen@...ux.intel.com>
> Subject: [PATCH] pci-dma: Fix x86 dma_alloc_coherent to fully clear all pages returned
> 
> 
> Commit d92ef66c4f8f ("x86: make dma_alloc_coherent() return zeroed memory
> if CMA is enabled") changed the dma_alloc_coherent page clearance from
> using an __GFP_ZERO in page allocation to not setting the flag but doing
> an explicit memory clear at the end.
> 
> However the memory clear only covered the memory size that
> was requested, but may not be up to the full extent of the
> last page, if the total pages returned exceed the
> memory size requested.  This behavior has caused problem with XHCI
> and caused it to hang:
> 
> kernel: xhci_hcd 0000:00:14.0: Stopped the command ring failed, maybe the host is dead
> kernel: xhci_hcd 0000:00:14.0: Abort command ring failed
> kernel: xhci_hcd 0000:00:14.0: HC died; cleaning up
> kernel: xhci_hcd 0000:00:14.0: Error while assigning device slot ID
> kernel: xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 64.
> 
> Other drivers may have similar issue if it assumes that the pages
> allocated are completely zeroed.
> 
> This patch ensures that the pages returned are fully cleared.
> 
> Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
> Cc: <stable@...r.kernel.org> # 3.16+
> 
> ---
>  arch/x86/kernel/pci-dma.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
> index a25e202..e9d8dee 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -125,6 +125,8 @@ again:
>  
>  		return NULL;
>  	}
> +	/* round up to full page size */
> +	size = (size + ~PAGE_MASK) & PAGE_MASK;

Hi, is this an open-coded version of PAGE_ALIGN?

>  	memset(page_address(page), 0, size);
>  	*dma_addr = addr;
>  	return page_address(page);
> 


-- 
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ