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, 17 Feb 2014 14:05:33 +0530
From:	Vinod Koul <vinod.koul@...el.com>
To:	Siva Yerramreddy <siva.krishna.kumar.reddy.yerramreddy@...el.com>
Cc:	Dan Williams <dan.j.williams@...el.com>, dmaengine@...r.kernel.org,
	Sudeep Dutt <sudeep.dutt@...el.com>,
	Nikhil Rao <nikhil.rao@...el.com>,
	Ashutosh Dixit <ashutosh.dixit@...el.com>,
	linux-kernel@...r.kernel.org,
	Russell King <rmk+kernel@....linux.org.uk>
Subject: Re: [PATCH dmaengine-fixes 1/1] dmaengine: read completed cookie
 before used cookie

On Fri, Feb 14, 2014 at 03:32:57PM -0800, Siva Yerramreddy wrote:
> When running dmatest with my yet-to-be submitted driver for the Intel MIC DMA
> engine, dmatest detected "dma0chan3-copy5: result #8096161:completion busy
> status with src_off=0x0 dst_off=0x0 len=0x40 (0)". This is caused by reading
> the used cookie before the completed cookie in dma_cookie_status(),  if a DMA
> request is submitted in between the two reads, and completes,  the completed
> cookie will be newer than the used cookie value read previously.  Reversing
> the order of reads ensures that the completed cookie is for a DMA request
> older than the used cookie.
> 
> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@...el.com>
> Reviewed-by: Sudeep Dutt <sudeep.dutt@...el.com>
> Reviewed-by: Nikhil Rao <nikhil.rao@...el.com>
> Signed-off-by: Siva Yerramreddy <siva.krishna.kumar.reddy.yerramreddy@...el.com>
> ---
>  drivers/dma/dmaengine.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
> index 17f983a..4c96892 100644
> --- a/drivers/dma/dmaengine.h
> +++ b/drivers/dma/dmaengine.h
> @@ -7,6 +7,7 @@
>  
>  #include <linux/bug.h>
>  #include <linux/dmaengine.h>
> +#include <asm/barrier.h>
>  
>  /**
>   * dma_cookie_init - initialize the cookies for a DMA channel
> @@ -69,8 +70,13 @@ static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
>  {
>  	dma_cookie_t used, complete;
>  
> -	used = chan->cookie;
>  	complete = chan->completed_cookie;
> +	/*
> +	 * If this order is not maintained, used can end up being older than
> +	 * complete
> +	 */
> +	smp_rmb();
> +	used = chan->cookie;
>  	barrier();
>  	if (state) {
>  		state->last = complete;
The idea is right to grab the channle cookie after completed. But I dont see why
you need another barrier in between these two?

Dan,

This really is intresting case where the request completed raced with status.
I am sure for us slow slave users we may not see such issues :D but for these
and other memcpy cases do we really need to bother checking the status properly
and getting right data or delayed reporting is fine?

-- 
~Vinod
--
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