From: Jan Kara <jack@suse.cz>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, tytso@mit.edu, bpm@sgi.com,
jlbec@evilplan.org, Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>,
stable@vger.kernel.org
Subject: Re: [PATCH 4/4] fs: Fix possible use-after-free with AIO
Date: Wed, 23 Jan 2013 20:18:58 +0100 [thread overview]
Message-ID: <20130123191858.GA21112@quack.suse.cz> (raw)
In-Reply-To: <x49fw1sx7ri.fsf@segfault.boston.devel.redhat.com>
On Wed 23-01-13 10:02:09, Jeff Moyer wrote:
> Jan Kara <jack@suse.cz> writes:
>
> > 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
> > 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);
> > }
>
> OK, so this is only a problem if nobody is waiting in inode_dio_wait,
> yes? Good catch, though it seems incredibly unlikely anyone would trip
> over this in practice (since fput is done in a worker thread, or
> deferred).
Yes, it's mostly a theoretical race.
> Acked-by: Jeff Moyer <jmoyer@redhat.com>
Thanks.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2013-01-23 19:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-23 12:56 [PATCH 0/4] Fix possible use after free with AIO Jan Kara
2013-01-23 12:56 ` [PATCH 1/4] ext4: Fix possible use-after-free " Jan Kara
2013-01-23 13:18 ` Carlos Maiolino
2013-01-23 12:56 ` [PATCH 2/4] xfs: " Jan Kara
2013-01-23 22:00 ` Ben Myers
2013-01-23 12:56 ` [PATCH 3/4] ocfs2: " Jan Kara
2013-01-23 12:56 ` [PATCH 4/4] fs: " Jan Kara
2013-01-23 15:02 ` Jeff Moyer
2013-01-23 19:18 ` Jan Kara [this message]
2013-01-23 16:03 ` [PATCH 0/4] Fix possible use after free " Jeff Moyer
-- strict thread matches above, loose matches on Subject: below --
2013-01-29 23:27 [PATCH 0/4 v2] " Jan Kara
2013-01-29 23:28 ` [PATCH 4/4] fs: Fix possible use-after-free " 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=20130123191858.GA21112@quack.suse.cz \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=bpm@sgi.com \
--cc=hch@infradead.org \
--cc=jlbec@evilplan.org \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
/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).