io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring/msg_ring: let target know allocated index
@ 2023-03-16 12:11 Pavel Begunkov
  2023-03-16 12:14 ` Pavel Begunkov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-03-16 12:11 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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: e6130eba8a848 ("io_uring: add support for passing fixed file descriptors")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/msg_ring.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index 8803c0979e2a..85fd7ce5f05b 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -202,7 +202,7 @@ static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flag
 	 * 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))
+	if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0))
 		ret = -EOVERFLOW;
 out_unlock:
 	io_double_unlock_ctx(target_ctx);
@@ -229,6 +229,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
 	struct io_ring_ctx *ctx = req->ctx;
 	struct file *src_file = msg->src_file;
 
+	if (msg->len)
+		return -EINVAL;
 	if (target_ctx == ctx)
 		return -EINVAL;
 	if (target_ctx->flags & IORING_SETUP_R_DISABLED)
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/1] io_uring/msg_ring: let target know allocated index
  2023-03-16 12:11 [PATCH 1/1] io_uring/msg_ring: let target know allocated index Pavel Begunkov
@ 2023-03-16 12:14 ` Pavel Begunkov
  2023-03-16 12:29 ` Pavel Begunkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-03-16 12:14 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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: e6130eba8a848 ("io_uring: add support for passing fixed file descriptors")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/msg_ring.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index 8803c0979e2a..85fd7ce5f05b 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -202,7 +202,7 @@ static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flag
 	 * 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))
+	if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0))
 		ret = -EOVERFLOW;
 out_unlock:
 	io_double_unlock_ctx(target_ctx);
@@ -229,6 +229,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
 	struct io_ring_ctx *ctx = req->ctx;
 	struct file *src_file = msg->src_file;
 
+	if (msg->len)
+		return -EINVAL;
 	if (target_ctx == ctx)
 		return -EINVAL;
 	if (target_ctx->flags & IORING_SETUP_R_DISABLED)
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/msg_ring: let target know allocated index
  2023-03-16 12:11 [PATCH 1/1] io_uring/msg_ring: let target know allocated index Pavel Begunkov
  2023-03-16 12:14 ` Pavel Begunkov
@ 2023-03-16 12:29 ` Pavel Begunkov
  2023-03-16 13:10 ` Pavel Begunkov
  2023-03-16 13:17 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-03-16 12:29 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe

On 3/16/23 12:11, Pavel Begunkov wrote:
> 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.

Weird, there are two identical mails with the patch, please
ignore either of them.

  
> 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: e6130eba8a848 ("io_uring: add support for passing fixed file descriptors")
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>   io_uring/msg_ring.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
> index 8803c0979e2a..85fd7ce5f05b 100644
> --- a/io_uring/msg_ring.c
> +++ b/io_uring/msg_ring.c
> @@ -202,7 +202,7 @@ static int io_msg_install_complete(struct io_kiocb *req, unsigned int issue_flag
>   	 * 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))
> +	if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0))
>   		ret = -EOVERFLOW;
>   out_unlock:
>   	io_double_unlock_ctx(target_ctx);
> @@ -229,6 +229,8 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
>   	struct io_ring_ctx *ctx = req->ctx;
>   	struct file *src_file = msg->src_file;
>   
> +	if (msg->len)
> +		return -EINVAL;
>   	if (target_ctx == ctx)
>   		return -EINVAL;
>   	if (target_ctx->flags & IORING_SETUP_R_DISABLED)

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/msg_ring: let target know allocated index
  2023-03-16 12:11 [PATCH 1/1] io_uring/msg_ring: let target know allocated index Pavel Begunkov
  2023-03-16 12:14 ` Pavel Begunkov
  2023-03-16 12:29 ` Pavel Begunkov
@ 2023-03-16 13:10 ` Pavel Begunkov
  2023-03-16 13:17 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2023-03-16 13:10 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe

On 3/16/23 12:11, Pavel Begunkov wrote:
> 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: e6130eba8a848 ("io_uring: add support for passing fixed file descriptors")
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

Link: https://github.com/axboe/liburing/issues/809


-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/msg_ring: let target know allocated index
  2023-03-16 12:11 [PATCH 1/1] io_uring/msg_ring: let target know allocated index Pavel Begunkov
                   ` (2 preceding siblings ...)
  2023-03-16 13:10 ` Pavel Begunkov
@ 2023-03-16 13:17 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2023-03-16 13:17 UTC (permalink / raw)
  To: io-uring, Pavel Begunkov


On Thu, 16 Mar 2023 12:11:42 +0000, Pavel Begunkov wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] io_uring/msg_ring: let target know allocated index
      commit: 5da28edd7bd5518f97175ecea77615bb729a7a28

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-16 13:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 12:11 [PATCH 1/1] io_uring/msg_ring: let target know allocated index Pavel Begunkov
2023-03-16 12:14 ` Pavel Begunkov
2023-03-16 12:29 ` Pavel Begunkov
2023-03-16 13:10 ` Pavel Begunkov
2023-03-16 13:17 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).