diff options
author | Jan Kara <jack@suse.cz> | 2013-01-30 07:48:17 +0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-01-30 07:48:17 +0400 |
commit | 091e26dfc156aeb3b73bc5c5f277e433ad39331c (patch) | |
tree | 03a95cea66597c0b7289ea6fbdc13785a5e21919 /fs/ext4/page-io.c | |
parent | b1deefc99e668348f7c785c6ece5f6ff4c6d8b5c (diff) | |
download | linux-091e26dfc156aeb3b73bc5c5f277e433ad39331c.tar.xz |
ext4: fix possible use-after-free with AIO
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: stable@vger.kernel.org
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/page-io.c')
-rw-r--r-- | fs/ext4/page-io.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 5d8c66948e1b..809b31003ecc 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -102,14 +102,13 @@ static int ext4_end_io(ext4_io_end_t *io) "(inode %lu, offset %llu, size %zd, error %d)", inode->i_ino, offset, size, ret); } - if (io->iocb) - aio_complete(io->iocb, io->result, 0); - - if (io->flag & EXT4_IO_END_DIRECT) - inode_dio_done(inode); /* Wake up anyone waiting on unwritten extent conversion */ if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten)) wake_up_all(ext4_ioend_wq(inode)); + if (io->flag & EXT4_IO_END_DIRECT) + inode_dio_done(inode); + if (io->iocb) + aio_complete(io->iocb, io->result, 0); return ret; } |