ocfs2: fix possible use-after-free with AIO
authorJan Kara <[email protected]>
Wed, 20 Feb 2013 02:16:39 +0000 (13:16 +1100)
committerAl Viro <[email protected]>
Tue, 26 Feb 2013 07:46:12 +0000 (02:46 -0500)
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.

Signed-off-by: Jan Kara <[email protected]>
Acked-by: Jeff Moyer <[email protected]>
Acked-by: Joel Becker <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Al Viro <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Al Viro <[email protected]>
fs/ocfs2/aops.c

index db1ad26e02a759b7e2f669c1faebcf11f7d5c428..50fe28b988c1d27167c112d72195e11f28a78b12 100644 (file)
@@ -593,9 +593,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
        level = ocfs2_iocb_rw_locked_level(iocb);
        ocfs2_rw_unlock(inode, level);
 
+       inode_dio_done(inode);
        if (is_async)
                aio_complete(iocb, ret, 0);
-       inode_dio_done(inode);
 }
 
 /*