]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: fix io_req_prep_async with provided buffers
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 10 Feb 2025 17:27:55 +0000 (17:27 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 12:49:53 +0000 (13:49 +0100)
io_req_prep_async() can import provided buffers, commit the ring state
by giving up on that before, it'll be reimported later if needed.

Reported-by: Muhammad Ramdhan <ramdhan@starlabs.sg>
Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
Reported-by: Jacob Soo <jacob.soo@starlabs.sg>
Fixes: c7fb19428d67d ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/io_uring.c

index 64502323be5e556cf5a4837cc1d13cb147467c8c..33597284e1cb507e34e102c186abff48217fc6f6 100644 (file)
@@ -1624,6 +1624,7 @@ bool io_alloc_async_data(struct io_kiocb *req)
 int io_req_prep_async(struct io_kiocb *req)
 {
        const struct io_op_def *def = &io_op_defs[req->opcode];
+       int ret;
 
        /* assign early for deferred execution for non-fixed file */
        if (def->needs_file && !(req->flags & REQ_F_FIXED_FILE) && !req->file)
@@ -1636,7 +1637,9 @@ int io_req_prep_async(struct io_kiocb *req)
                if (io_alloc_async_data(req))
                        return -EAGAIN;
        }
-       return def->prep_async(req);
+       ret = def->prep_async(req);
+       io_kbuf_recycle(req, 0);
+       return ret;
 }
 
 static u32 io_get_sequence(struct io_kiocb *req)