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: <20131206152654.GD13581@kvack.org>
Date:	Fri, 6 Dec 2013 10:26:54 -0500
From:	Benjamin LaHaise <bcrl@...ck.org>
To:	Gu Zheng <guz.fnst@...fujitsu.com>
Cc:	linux-aio@...ck.org, fsdevel <linux-fsdevel@...r.kernel.org>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	Dave Jones <davej@...hat.com>,
	Al Viro <viro@...iv.linux.org.uk>, Kent <kmo@...erainc.com>,
	Kristian Nielsen <knielsen@...elsen-hq.org>
Subject: Re: [PATCH] aio: clean up aio ring in the fail path

On Wed, Dec 04, 2013 at 06:19:06PM +0800, Gu Zheng wrote:
> Clean up the aio ring file in the fail path of aio_setup_ring
> and ioctx_alloc. And maybe it can fix the GPF issue reported by
> Dave Jones:
> https://lkml.org/lkml/2013/11/25/898

Good catch.  I've applied this to my aio-next tree.  It does indeed look 
like it could be the cause of Dave's GPF -- I'll try to trigger it with 
some other kernel debug options on and see if the EAGAIN failure case can 
trip it up.

		-ben

> Signed-off-by: Gu Zheng <guz.fnst@...fujitsu.com>
> ---
>  fs/aio.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 08159ed..6efb7f6 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
>  	if (nr_pages > AIO_RING_PAGES) {
>  		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
>  					  GFP_KERNEL);
> -		if (!ctx->ring_pages)
> +		if (!ctx->ring_pages) {
> +			put_aio_ring_file(ctx);
>  			return -ENOMEM;
> +		}
>  	}
>  
>  	ctx->mmap_size = nr_pages * PAGE_SIZE;
> @@ -645,7 +647,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
>  	    aio_nr + nr_events < aio_nr) {
>  		spin_unlock(&aio_nr_lock);
>  		err = -EAGAIN;
> -		goto err;
> +		goto err_ctx;
>  	}
>  	aio_nr += ctx->max_reqs;
>  	spin_unlock(&aio_nr_lock);
> @@ -662,6 +664,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
>  
>  err_cleanup:
>  	aio_nr_sub(ctx->max_reqs);
> +err_ctx:
> +	aio_free_ring(ctx);
>  err:
>  	free_percpu(ctx->cpu);
>  	free_percpu(ctx->reqs.pcpu_count);
> -- 
> 1.7.7
> 

-- 
"Thought is the essence of where you are now."
--
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