From: Jan Kara Subject: [PATCH 4/4] fs: Fix possible use-after-free with AIO Date: Wed, 30 Jan 2013 00:28:01 +0100 Message-ID: <1359502081-20240-5-git-send-email-jack@suse.cz> References: <1359502081-20240-1-git-send-email-jack@suse.cz> Cc: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com, linux-ext4@vger.kernel.org, ocfs2-devel@oss.oracle.com, Jan Kara , Christoph Hellwig , Jens Axboe , Jeff Moyer , stable@vger.kernel.org To: Al Viro Return-path: Received: from cantor2.suse.de ([195.135.220.15]:50219 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344Ab3A2X2R (ORCPT ); Tue, 29 Jan 2013 18:28:17 -0500 In-Reply-To: <1359502081-20240-1-git-send-email-jack@suse.cz> Sender: linux-ext4-owner@vger.kernel.org List-ID: Running AIO is pinning inode in memory using file reference. Once AIO is completed using aio_complete(), file reference is put and inode can be freed from memory. So we have to be sure that calling aio_complete() is the last thing we do with the inode. CC: Christoph Hellwig CC: Jens Axboe CC: Jeff Moyer CC: stable@vger.kernel.org Acked-by: Jeff Moyer Signed-off-by: Jan Kara --- fs/direct-io.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index cf5b44b..f853263 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -261,9 +261,9 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is dio->end_io(dio->iocb, offset, transferred, dio->private, ret, is_async); } else { + inode_dio_done(dio->inode); if (is_async) aio_complete(dio->iocb, ret, 0); - inode_dio_done(dio->inode); } return ret; -- 1.7.1