From: Pavel Begunkov Date: Mon, 20 Mar 2023 13:05:02 +0000 (-0600) Subject: io_uring/msg_ring: let target know allocated index X-Git-Tag: baikal/mips/sdk6.1~5 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=6dc5c797710ede18f961b538a74dc3c0e7b48a71;p=kernel.git io_uring/msg_ring: let target know allocated index commit 555f426c0eee43e4a5f8e011f0a20aa896462278 upstream. msg_ring requests transferring files support auto index selection via IORING_FILE_INDEX_ALLOC, however they don't return the selected index to the target ring and there is no other good way for the userspace to know where is the receieved file. Return the index for allocated slots and 0 otherwise, which is consistent with other fixed file installing requests. Cc: stable@vger.kernel.org # v6.0+ Fixes: 08835f2466589 ("io_uring: add support for passing fixed file descriptors") Signed-off-by: Pavel Begunkov Link: https://github.com/axboe/liburing/issues/809 Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c index 7d5b544cfc305..3526389ac2180 100644 --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -84,6 +84,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags) struct file *src_file; int ret; + if (msg->len) + return -EINVAL; if (target_ctx == ctx) return -EINVAL; if (target_ctx->flags & IORING_SETUP_R_DISABLED) @@ -120,7 +122,7 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags) * completes with -EOVERFLOW, then the sender must ensure that a * later IORING_OP_MSG_RING delivers the message. */ - if (!io_post_aux_cqe(target_ctx, msg->user_data, msg->len, 0, true)) + if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0, true)) ret = -EOVERFLOW; out_unlock: io_double_unlock_ctx(ctx, target_ctx, issue_flags);