From: Al Viro <viro@ZenIV.linux.org.uk>
To: Christoph Hellwig <hch@lst.de>
Cc: torvalds@linux-foundation.org, jack@suse.cz,
dmonakhov@openvz.org, jmoyer@redhat.com,
linux-fsdevel@vger.kernel.org, linux-aio@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] aio: fix a user triggered use after free (and fix freeze protection of aio writes)
Date: Sat, 29 Oct 2016 17:29:46 +0100 [thread overview]
Message-ID: <20161029162946.GS19539@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20161029161230.GR19539@ZenIV.linux.org.uk>
On Sat, Oct 29, 2016 at 05:12:30PM +0100, Al Viro wrote:
> NAK, with apologies for not having looked at that earlier. The bug is real,
> all right, but this is not a solution - both incomplete and far too brittle.
>
> Why do we play that kind of insane games, anyway? Why not e.g. refcount
> the (async) iocb and have kiocb_free() drop the reference, with io_submit_one()
> holding one across the call of aio_run_iocb()? Cacheline bouncing issues?
> Anything more subtle?
PS: I'm not saying that refcounting kiocb is the best solution - grabbing an
extra reference to struct file might be better (we have just dirtied that
cacheline, so the fact that struct file is shared more than kiocb shouldn't
matter much), but I really think that "file and everything attached to it
might disappear as soon as you get async IO started" is insanely brittle -
e.g. xfs_rw_iunlock(ip, iolock) in xfs_file_dio_aio_write() is also unsafe
<checks -next - yup, still there>
If struct file might be gone, so might struct inode and everything behind
it. Which means that we either are not allowed to hold any locks across
__blockdev_direct_IO(), or need have end_io() callback taking care of
dropping those (and adjust the callers accordingly). It might be not
impossible, but... *ouch*
next prev parent reply other threads:[~2016-10-29 16:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1477727070-18806-1-git-send-email-hch@lst.de>
2016-10-29 7:44 ` [PATCH] aio: fix a user triggered use after free (and fix freeze protection of aio writes) Christoph Hellwig
2016-10-29 12:24 ` Al Viro
2016-10-29 15:20 ` Christoph Hellwig
2016-10-29 16:12 ` Al Viro
2016-10-29 16:29 ` Al Viro [this message]
2016-10-30 6:32 ` Christoph Hellwig
2016-10-29 17:47 ` Linus Torvalds
2016-10-29 18:52 ` Al Viro
2016-10-29 19:07 ` Linus Torvalds
2016-10-29 19:17 ` Al Viro
2016-10-29 20:09 ` Linus Torvalds
2016-10-30 9:44 ` Jan Kara
2016-10-30 10:52 ` Jan Kara
2016-10-30 15:58 ` Christoph Hellwig
2016-10-30 6:29 ` Christoph Hellwig
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=20161029162946.GS19539@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=dmonakhov@openvz.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jmoyer@redhat.com \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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).