From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: Chris Mason <mason@kernel.org>, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 08/10] io_uring/net: don't count the buffers of a send bundle
Date: Wed, 25 Nov 2026 11:43:17 -0700 [thread overview]
Message-ID: <20261125184439.58077-9-axboe@kernel.dk> (raw)
In-Reply-To: <20261125184439.58077-1-axboe@kernel.dk>
From: Chris Mason <mason@kernel.org>
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 f8d547c5e7d6..9c69f37cb8aa 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -515,12 +515,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-11-25 18:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:43 [PATCHSET 0/10] Various fixes Jens Axboe
2026-11-25 18:43 ` [PATCH 01/10] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-11-25 18:43 ` [PATCH 02/10] io_uring/kbuf: clear REQ_F_BL_NO_RECYCLE on buffer put Jens Axboe
2026-11-25 18:43 ` [PATCH 03/10] io_uring: free the ring after a grace period Jens Axboe
2026-11-25 18:43 ` [PATCH 04/10] io_uring: free the ring from an RCU work Jens Axboe
2026-11-25 18:43 ` [PATCH 05/10] io_uring/filetable: don't install O_PATH files Jens Axboe
2026-11-25 18:43 ` [PATCH 06/10] io_uring/timeout: hold timeout_lock for the link splice Jens Axboe
2026-11-25 18:43 ` [PATCH 07/10] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-11-25 18:43 ` Jens Axboe [this message]
2026-11-25 18:43 ` [PATCH 09/10] io_uring: drop cached task refs on ring release Jens Axboe
2026-11-25 18:43 ` [PATCH 10/10] io_uring/net: restore the cmsg buffer on recvmsg retry 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=20261125184439.58077-9-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=mason@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.