From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932342AbbFQS0h (ORCPT ); Wed, 17 Jun 2015 14:26:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38384 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757083AbbFQS0b (ORCPT ); Wed, 17 Jun 2015 14:26:31 -0400 From: Jeff Moyer To: Oleg Nesterov Cc: Al Viro , Andrew Morton , Benjamin LaHaise , linux-aio@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] aio_free_ring: don't do page_count(NULL) References: <20150616230431.GA15800@redhat.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Wed, 17 Jun 2015 14:26:28 -0400 In-Reply-To: <20150616230431.GA15800@redhat.com> (Oleg Nesterov's message of "Wed, 17 Jun 2015 01:04:31 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > aio_free_ring() can actually see the NULL page in ->ring_pages[], > this can happen if aio_setup_ring() fails. > > And in this case page_count(ctx->ring_pages[i]) can OOPS. > > Signed-off-by: Oleg Nesterov I'm not sure the reformatting was necessary, but whatever. Reviewed-by: Jeff Moyer > --- > fs/aio.c | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/aio.c b/fs/aio.c > index b605ab2..666fbb8 100644 > --- a/fs/aio.c > +++ b/fs/aio.c > @@ -292,12 +292,12 @@ static void aio_free_ring(struct kioctx *ctx) > put_aio_ring_file(ctx); > > for (i = 0; i < ctx->nr_pages; i++) { > - struct page *page; > - pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i, > - page_count(ctx->ring_pages[i])); > - page = ctx->ring_pages[i]; > + struct page *page = ctx->ring_pages[i]; > if (!page) > continue; > + > + pr_debug("pid(%d) [%d] page->count=%d\n", > + current->pid, i, page_count(page)); > ctx->ring_pages[i] = NULL; > put_page(page); > }