Skip to content

Commit 5da28ed

Browse files
isilenceaxboe
authored andcommitted
io_uring/msg_ring: let target know allocated index
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: e6130eb ("io_uring: add support for passing fixed file descriptors") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: axboe/liburing#809 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6acd352 commit 5da28ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

io_uring/msg_ring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flag
202202
* completes with -EOVERFLOW, then the sender must ensure that a
203203
* later IORING_OP_MSG_RING delivers the message.
204204
*/
205-
if (!io_post_aux_cqe(target_ctx, msg->user_data, msg->len, 0))
205+
if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0))
206206
ret = -EOVERFLOW;
207207
out_unlock:
208208
io_double_unlock_ctx(target_ctx);
@@ -229,6 +229,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
229229
struct io_ring_ctx *ctx = req->ctx;
230230
struct file *src_file = msg->src_file;
231231

232+
if (msg->len)
233+
return -EINVAL;
232234
if (target_ctx == ctx)
233235
return -EINVAL;
234236
if (target_ctx->flags & IORING_SETUP_R_DISABLED)

0 commit comments

Comments
 (0)