public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH 1/2] io_uring: check for user passing 0 nr_submit
Date: Tue, 14 Oct 2025 11:58:09 +0100	[thread overview]
Message-ID: <1a39321ae5b863708e736d5e9e9ff7533bed7c32.1760438982.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1760438982.git.asml.silence@gmail.com>

io_submit_sqes() shouldn't be stepping into its main loop when there is
nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks,
which should follow after all user input truncations.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/io_uring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 820ef0527666..ee04ab9bf968 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2422,10 +2422,11 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
 	unsigned int left;
 	int ret;
 
+	entries = min(nr, entries);
 	if (unlikely(!entries))
 		return 0;
-	/* make sure SQ entry isn't read before tail */
-	ret = left = min(nr, entries);
+
+	ret = left = entries;
 	io_get_task_refs(left);
 	io_submit_state_start(&ctx->submit_state, left);
 
-- 
2.49.0


  reply	other threads:[~2025-10-14 10:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 10:58 [PATCH 0/2] Introduce non circular SQ Pavel Begunkov
2025-10-14 10:58 ` Pavel Begunkov [this message]
2025-10-14 10:58 ` [PATCH 2/2] io_uring: introduce non-circular SQ Pavel Begunkov
2025-10-14 17:21   ` Jens Axboe
2025-10-14 18:58     ` Pavel Begunkov
2025-10-14 18:37   ` Caleb Sander Mateos
2025-10-14 19:26     ` Pavel Begunkov
2025-10-14 19:46       ` Caleb Sander Mateos
2025-10-16 11:38         ` Pavel Begunkov
2025-10-14 15:05 ` [PATCH 0/2] Introduce non circular SQ Jens Axboe
2025-10-14 16:02   ` Pavel Begunkov
2025-10-14 16:08     ` Pavel Begunkov
2025-10-14 17:19       ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a39321ae5b863708e736d5e9e9ff7533bed7c32.1760438982.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox