io_uring: fix race around poll update and poll triggering
authorJens Axboe <axboe@kernel.dk>
Wed, 31 Mar 2021 15:03:03 +0000 (09:03 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 4 Apr 2021 21:28:18 +0000 (15:28 -0600)
commitf131a8470cbb18eef54257f3dc4e99ff502d26a7
tree1a3d3d5b81053e7f56198130d7a5a59b648c9ae6
parentf8df76ff8293a79e8f0287818d2e4c435b126f99
io_uring: fix race around poll update and poll triggering

Joakim reports that in some conditions he sees a multishot poll request
being canceled, and that it coincides with getting -EALREADY on
modification. As part of the poll update procedure, there's a small window
where the request is marked as canceled, and if this coincides with the
event actually triggering, then we can get a spurious -ECANCELED and
termination of the multishot request.

Don't mark the poll request as being canceled for update. We also don't
care if we race on removal unless it's a one-shot request, we can safely
updated for either case.

Fixes: 4d636d877e82 ("io_uring: allow events and user_data update of running poll requests")
Reported-by: Joakim Hassila <joj@mac.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c