diff options
author | Gabriel Krisman Bertazi | 2023-10-04 20:05:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman | 2023-11-20 11:52:00 +0100 |
commit | 60db638be5f4eb6cecb1de86c545008784ccd749 (patch) | |
tree | 4eb6aeeb855935403140b1b99ef5a211c9ddba4e /io_uring | |
parent | 03e334565d2d67673d7405b5b4a746da0fc20f71 (diff) |
io_uring/kbuf: Fix check of BID wrapping in provided buffers
[ Upstream commit ab69838e7c75b0edb699c1a8f42752b30333c46f ]
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 <krisman@suse.de>
Link: https://lore.kernel.org/r/20231005000531.30800-2-krisman@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/kbuf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index acc37e5a6d4e..e45602b02a9f 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -347,7 +347,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; |