linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	David Miller <davem@davemloft.net>,
	Jason Baron <jbaron@akamai.com>,
	kgraul@linux.ibm.com, ktkhai@virtuozzo.com,
	kyeongdon.kim@lge.com,
	Linux List Kernel Mailing <linux-kernel@vger.kernel.org>,
	Netdev <netdev@vger.kernel.org>,
	pabeni@redhat.com, syzkaller-bugs@googlegroups.com,
	xiyou.wangcong@gmail.com, zhengbin <zhengbin13@huawei.com>,
	bcrl@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com
Subject: Re: [PATCH 4/8] Fix aio_poll() races
Date: Tue, 12 Mar 2019 20:18:01 +0100	[thread overview]
Message-ID: <20190312191801.GA5236@lst.de> (raw)
In-Reply-To: <20190311210618.GL2217@ZenIV.linux.org.uk>

On Mon, Mar 11, 2019 at 09:06:18PM +0000, Al Viro wrote:
> On Mon, Mar 11, 2019 at 08:58:31PM +0100, Christoph Hellwig wrote:
> > Where do we put the second iocb reference in case we return from
> > vfs_poll without ever being woken?
> 
> Depends.  If mask is non-zero (i.e. vfs_poll() has returned something
> we care about) and it has never been woken, we steal it and drop the
> reference ourselves.  If it is zero and we see that ->poll() has tried
> to put it on two queues, we steal it (again, assuming it's not on
> waitqueue and _can_ be stolen) and return -EINVAL.  In that case
> __io_submit_one() (or, by the end of the series, io_submit_one())
> will call iocb_destroy().  And in the normal waiting case (nothing
> interesting reported and no errors) it will end up on the list of
> cancellables.  Then it either will get completed by later wakeup, which
> will drop the reference, or it will get eventually cancelled, which will
> hit the same aio_poll_complete_work() and drop the reference...

Ok, seems like the logic is sane.  I was missing how the actual
mask logic worked in aio_poll().

> > Also it seems like the complete code would still benefit from a little
> > helper, something like:
> 
> Umm...  Not sure I like the name (something like aio_poll_done() seems
> to be better), but other than that - no problem.

I don't care about the name.  Feel free to change it to whatever suits
you.

  reply	other threads:[~2019-03-12 19:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHk-=wghRmdYKRAwakeHmjcpbLt9fJAHyU2x8s_NZONhz6RTOw@mail.gmail.com>
2019-03-07  0:03 ` [PATCH 1/8] aio: make sure file is pinned Al Viro
2019-03-07  0:03   ` [PATCH 2/8] aio_poll_wake(): don't set ->woken if we ignore the wakeup Al Viro
2019-03-07  2:18     ` Al Viro
2019-03-08 11:16       ` zhengbin (A)
2019-03-07  0:03   ` [PATCH 3/8] aio_poll(): sanitize the logics after vfs_poll(), get rid of leak on error Al Viro
2019-03-07  2:11     ` zhengbin (A)
2019-03-07  0:03   ` [PATCH 4/8] aio_poll(): get rid of weird refcounting Al Viro
2019-03-07  0:03   ` [PATCH 5/8] make aio_read()/aio_write() return int Al Viro
2019-03-07  0:03   ` [PATCH 6/8] move dropping ->ki_eventfd into iocb_put() Al Viro
2019-03-07  0:03   ` [PATCH 7/8] deal with get_reqs_available() in aio_get_req() itself Al Viro
2019-03-07  0:03   ` [PATCH 8/8] aio: move sanity checks and request allocation to io_submit_one() Al Viro
2019-03-07  0:23   ` [PATCH 1/8] aio: make sure file is pinned Linus Torvalds
2019-03-07  0:41     ` Al Viro
2019-03-07  0:48       ` Al Viro
2019-03-07  1:20         ` Al Viro
2019-03-07  1:30           ` Linus Torvalds
2019-03-08  3:36             ` Al Viro
2019-03-08 15:50               ` Christoph Hellwig
2019-03-10  7:06               ` Al Viro
2019-03-10  7:08                 ` [PATCH 1/8] pin iocb through aio Al Viro
2019-03-10  7:08                   ` [PATCH 2/8] keep io_event in aio_kiocb Al Viro
2019-03-11 19:43                     ` Christoph Hellwig
2019-03-11 21:17                       ` Al Viro
2019-03-10  7:08                   ` [PATCH 3/8] aio: store event at final iocb_put() Al Viro
2019-03-11 19:44                     ` Christoph Hellwig
2019-03-11 21:13                       ` Al Viro
2019-03-11 22:52                         ` Al Viro
2019-03-10  7:08                   ` [PATCH 4/8] Fix aio_poll() races Al Viro
2019-03-11 19:58                     ` Christoph Hellwig
2019-03-11 21:06                       ` Al Viro
2019-03-12 19:18                         ` Christoph Hellwig [this message]
2019-03-10  7:08                   ` [PATCH 5/8] make aio_read()/aio_write() return int Al Viro
2019-03-11 19:44                     ` Christoph Hellwig
2019-03-10  7:08                   ` [PATCH 6/8] move dropping ->ki_eventfd into iocb_destroy() Al Viro
2019-03-11 19:46                     ` Christoph Hellwig
2019-03-10  7:08                   ` [PATCH 7/8] deal with get_reqs_available() in aio_get_req() itself Al Viro
2019-03-11 19:46                     ` Christoph Hellwig
2019-03-10  7:08                   ` [PATCH 8/8] aio: move sanity checks and request allocation to io_submit_one() Al Viro
2019-03-11 19:48                     ` Christoph Hellwig
2019-03-11 21:12                       ` Al Viro
2019-03-11 19:41                   ` [PATCH 1/8] pin iocb through aio Christoph Hellwig
2019-03-11 19:41                 ` [PATCH 1/8] aio: make sure file is pinned 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=20190312191801.GA5236@lst.de \
    --to=hch@lst.de \
    --cc=bcrl@kvack.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=houtao1@huawei.com \
    --cc=jbaron@akamai.com \
    --cc=kgraul@linux.ibm.com \
    --cc=ktkhai@virtuozzo.com \
    --cc=kyeongdon.kim@lge.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yi.zhang@huawei.com \
    --cc=zhengbin13@huawei.com \
    /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).