[Ocfs2-devel] [PATCH 2/4] xfs: Fix possible use-after-free with AIO

Jan Kara jack at suse.cz
Tue Jan 29 15:27:59 PST 2013


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: xfs at oss.sgi.com
CC: Ben Myers <bpm at sgi.com>
CC: stable at vger.kernel.org
Reviewed-by: Ben Myers <bpm at sgi.com>
Acked-by: Jeff Moyer <jmoyer at redhat.com>
Signed-off-by: Jan Kara <jack at suse.cz>
---
 fs/xfs/xfs_aops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 4111a40..5f707e5 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -86,11 +86,11 @@ xfs_destroy_ioend(
 	}
 
 	if (ioend->io_iocb) {
+		inode_dio_done(ioend->io_inode);
 		if (ioend->io_isasync) {
 			aio_complete(ioend->io_iocb, ioend->io_error ?
 					ioend->io_error : ioend->io_result, 0);
 		}
-		inode_dio_done(ioend->io_inode);
 	}
 
 	mempool_free(ioend, xfs_ioend_pool);
-- 
1.7.1




More information about the Ocfs2-devel mailing list