From: Jens Axboe <axboe@kernel.dk>
To: stable@vger.kernel.org
Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org
Subject: [PATCH 6.12.y 11/15] io_uring/net: don't count the buffers of a send bundle
Date: Sat, 5 Dec 2026 23:11:03 +0000 [thread overview]
Message-ID: <20261205231107.4023506-12-axboe@kernel.dk> (raw)
In-Reply-To: <20261205231107.4023506-1-axboe@kernel.dk>
From: Chris Mason <mason@kernel.org>
Commit 449c7dc8502404b3a95ffa75cf5b54be5350fc49 upstream.
A bundle send on a packet socket with a TX ring can cause a
slab-out-of-bounds read, if the frames in the ring hold more bytes than
the iovecs of the send.
io_send_finish() hands the result of the send to io_bundle_nbufs(),
which walks the iovec array and subtracts each iov_len from the result.
The walk only stops at zero, so the iovecs have to cover the result. But
io_send() only tests if the result is below the count of the iter, and
tpacket_snd() ignores msg_iter and returns the length of the frames that
it took from the TX ring:
iovecs = 2, of 1 byte each
frames in the TX ring = 1, of 64 bytes
sock_sendmsg() = 64
64 - iov[0].iov_len = 63
63 - iov[1].iov_len = 62
62 - iov[2].iov_len is out of bounds
The send side doesn't use the number of buffers: io_buffers_select()
commits them at selection, so at completion io_kbuf_commit() returns
before it reads the number.
The fix used here is to put the buffers of a send bundle without
counting them, so that nothing walks the iovecs with the result of the
send.
Fixes: a05d1f625c7a ("io_uring/net: support bundles for send")
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/net.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index cc92e892fb53..01a3ad67474b 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -535,12 +535,10 @@ static inline bool io_send_finish(struct io_kiocb *req,
bool bundle_finished = sel->val <= 0;
unsigned int cflags;
- if (!(sr->flags & IORING_RECVSEND_BUNDLE)) {
- cflags = io_put_kbuf(req, sel->val, sel->buf_list);
+ /* Committed at selection time, so a bundle needs no buffer count */
+ cflags = io_put_kbuf(req, sel->val, sel->buf_list);
+ if (!(sr->flags & IORING_RECVSEND_BUNDLE))
goto finish;
- }
-
- cflags = io_put_kbufs(req, sel->val, sel->buf_list, io_bundle_nbufs(kmsg, sel->val));
/*
* Don't start new bundles if the buffer list is empty, or if the
--
2.55.0
next prev parent reply other threads:[~2026-12-05 23:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 23:10 [PATCH 6.12.y 00/15] io_uring fixes for 6.12-stable Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 01/15] io_uring/net: don't charge the folio offset to truesize for managed frags Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 02/15] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 03/15] io_uring/kbuf: clear REQ_F_BL_NO_RECYCLE on buffer put Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 04/15] io_uring/tctx: add separate lock for list of tctx's in ctx Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 05/15] io_uring: free the task context after a grace period Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 06/15] io_uring: free the ring " Jens Axboe
2026-12-05 23:10 ` [PATCH 6.12.y 07/15] io_uring/filetable: don't install O_PATH files Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 08/15] io_uring: make ctx->timeout_lock a raw spinlock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 09/15] io_uring/timeout: flush timeouts outside of the timeout lock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 10/15] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-12-05 23:11 ` Jens Axboe [this message]
2026-12-05 23:11 ` [PATCH 6.12.y 12/15] io_uring/net: restore the cmsg buffer on recvmsg retry Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 13/15] io_uring_poll: kill the no longer necessary barrier after poll_wait() Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 14/15] io_uring: close poll activation race when enabling rings Jens Axboe
2026-12-05 23:11 ` [PATCH 6.12.y 15/15] io_uring/cancel: arm local work wakeups only for submitter 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=20261205231107.4023506-12-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=io-uring@vger.kernel.org \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.