linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com,
	linux-ext4@vger.kernel.org, ocfs2-devel@oss.oracle.com,
	Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@infradead.org>,
	Jens Axboe <axboe@kernel.dk>, Jeff Moyer <jmoyer@redhat.com>,
	stable@vger.kernel.org
Subject: [PATCH 4/4] fs: Fix possible use-after-free with AIO
Date: Wed, 30 Jan 2013 00:28:01 +0100	[thread overview]
Message-ID: <1359502081-20240-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1359502081-20240-1-git-send-email-jack@suse.cz>

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 <hch@infradead.org>
CC: Jens Axboe <axboe@kernel.dk>
CC: Jeff Moyer <jmoyer@redhat.com>
CC: stable@vger.kernel.org
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 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


  parent reply	other threads:[~2013-01-29 23:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29 23:27 [PATCH 0/4 v2] Fix possible use after free with AIO Jan Kara
2013-01-29 23:27 ` [PATCH 1/4] ext4: Fix possible use-after-free " Jan Kara
2013-01-30  3:51   ` Theodore Ts'o
2013-01-29 23:27 ` [PATCH 2/4] xfs: " Jan Kara
2013-01-30  0:56   ` Ben Myers
2013-01-29 23:28 ` [PATCH 3/4] ocfs2: " Jan Kara
2013-01-29 23:28 ` Jan Kara [this message]
2013-01-30 14:45 ` [PATCH 0/4 v2] Fix possible use after free " Al Viro
2013-01-31  2:10   ` Li Zefan
2013-01-31 19:31   ` Joel Becker
  -- strict thread matches above, loose matches on Subject: below --
2013-01-23 12:56 [PATCH 0/4] " Jan Kara
2013-01-23 12:56 ` [PATCH 4/4] fs: Fix possible use-after-free " Jan Kara
2013-01-23 15:02   ` Jeff Moyer
2013-01-23 19:18     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359502081-20240-5-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=jmoyer@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).