]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: fix flush req->refs underflow
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 26 May 2020 17:34:02 +0000 (20:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jun 2020 14:42:01 +0000 (16:42 +0200)
commit 4518a3cc273cf82efdd36522fb1f13baad173c70 upstream.

In io_uring_cancel_files(), after refcount_sub_and_test() leaves 0
req->refs, it calls io_put_req(), which would also put a ref. Call
io_free_req() instead.

Cc: stable@vger.kernel.org
Fixes: 2ca10259b418 ("io_uring: prune request from overflow list on flush")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index 38052da4fdc5210c15d1f7e9d5ce531ae81b1b09..8276c3c42894c617a93dbea504829583e60616c2 100644 (file)
@@ -6529,7 +6529,7 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
                         * all we had, then we're done with this request.
                         */
                        if (refcount_sub_and_test(2, &cancel_req->refs)) {
-                               io_put_req(cancel_req);
+                               io_free_req(cancel_req);
                                finish_wait(&ctx->inflight_wait, &wait);
                                continue;
                        }