]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: ensure registered buffer import returns the IO length
authorJens Axboe <axboe@kernel.dk>
Wed, 13 Nov 2019 23:12:46 +0000 (16:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 15:49:10 +0000 (16:49 +0100)
commit 5e559561a8d7e6d4adfce6aa8fbf3daa3dec1577 upstream.

A test case was reported where two linked reads with registered buffers
failed the second link always. This is because we set the expected value
of a request in req->result, and if we don't get this result, then we
fail the dependent links. For some reason the registered buffer import
returned -ERROR/0, while the normal import returns -ERROR/length. This
broke linked commands with registered buffers.

Fix this by making io_import_fixed() correctly return the mapped length.

Cc: stable@vger.kernel.org # v5.3
Reported-by: 李通洲 <carter.li@eoitek.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index 37da4ea68f5091320ccbd6ee92b757e4ab43cd8a..56c23dee981175b87158ee70c1af09b439ceafb2 100644 (file)
@@ -1179,7 +1179,7 @@ static int io_import_fixed(struct io_ring_ctx *ctx, int rw,
                }
        }
 
-       return 0;
+       return len;
 }
 
 static ssize_t io_import_iovec(struct io_ring_ctx *ctx, int rw,