Skip to content

Commit

Permalink
fs: Fix possible use-after-free with AIO
Browse files Browse the repository at this point in the history
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 <[email protected]>
CC: Jens Axboe <[email protected]>
CC: Jeff Moyer <[email protected]>
CC: [email protected]
Acked-by: Jeff Moyer <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
jankara authored and Al Viro committed Feb 23, 2013
1 parent da2d845 commit 54c807e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 54c807e

Please sign in to comment.