From: Gabriel Krisman Bertazi <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Gabriel Krisman Bertazi <[email protected]>
Subject: [PATCH 1/3] io_uring: Fix check of BID wrapping in provided buffers
Date: Wed, 4 Oct 2023 20:05:29 -0400 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Commit 3851d25c75ed0 ("io_uring: check for rollover of buffer ID when
providing buffers") introduced a check to prevent wrapping the BID
counter when sqe->off is provided, but it's off-by-one too
restrictive, rejecting the last possible BID (65534).
i.e., the following fails with -EINVAL.
io_uring_prep_provide_buffers(sqe, addr, size, 0xFFFF, 0, 0);
Fixes: 3851d25c75ed ("io_uring: check for rollover of buffer ID when providing buffers")
Signed-off-by: Gabriel Krisman Bertazi <[email protected]>
---
io_uring/kbuf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index 556f4df25b0f..52dba81c3f50 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -352,7 +352,7 @@ int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
tmp = READ_ONCE(sqe->off);
if (tmp > USHRT_MAX)
return -E2BIG;
- if (tmp + p->nbufs >= USHRT_MAX)
+ if (tmp + p->nbufs > USHRT_MAX)
return -EINVAL;
p->bid = tmp;
return 0;
--
2.42.0
next prev parent reply other threads:[~2023-10-05 0:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 0:05 [PATCH 0/3] trivial fixes and a cleanup of provided buffers Gabriel Krisman Bertazi
2023-10-05 0:05 ` Gabriel Krisman Bertazi [this message]
2023-10-05 0:05 ` [PATCH 2/3] io_uring: Allow the full buffer id space for " Gabriel Krisman Bertazi
2023-10-05 0:05 ` [PATCH 3/3] io_uring: Use slab for struct io_buffer objects Gabriel Krisman Bertazi
2023-10-05 2:18 ` [PATCH 0/3] trivial fixes and a cleanup of provided buffers Jens Axboe
2023-10-05 14:25 ` Gabriel Krisman Bertazi
2023-10-05 14:38 ` 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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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