From: Jens Axboe <axboe@kernel.dk>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: io-uring@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] io_uring/net: don't overconsume buffers when using MSG_TRUNC
Date: Wed, 9 Sep 2026 07:58:41 -0600 [thread overview]
Message-ID: <01c58aa2-005c-49be-9d18-64d56d6fbb4b@kernel.dk> (raw)
In-Reply-To: <0f5e8693-dcba-4fa8-87d1-570ac08e2d83@kernel.dk>
On 9/9/26 7:56 AM, Jens Axboe wrote:
>> When a recv/recvmsg is issued with MSG_TRUNC and the incoming packet is
>> larger than the provided buffer, the net layer returns the full length
>> of the packet rather than the number of bytes actually copied into the
>> buffer. As a result, io_uring advances more of the provided buffer ring
>> than was actually filled. Use the actual filled region size to consume
>> the buffer, but still return the full size to preserve MSG_TRUNC
>> semantics.
>>
>> Take care with multishot, because that seems to already truncate the
>> consumption based on the available payload size.
>>
>> This was reported in https://github.com/axboe/liburing/issues/1619.
>>
>> Fixes: ae98dbf43d75 ("io_uring/kbuf: add support for incremental buffer consumption")
>> Cc: stable@vger.kernel.org
>> Link: https://patch.msgid.link/20260728191454.1850326-1-krisman@suse.de
>> Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
>> ---
>> io_uring/net.c | 38 +++++++++++++++++++++++++++++++-------
>> 1 file changed, 31 insertions(+), 7 deletions(-)
>>
>> diff --git a/io_uring/net.c b/io_uring/net.c
>> index 647156c9331a..f8110dc9f860 100644
>> --- a/io_uring/net.c
>> +++ b/io_uring/net.c
>> @@ -853,7 +853,7 @@ int io_recvmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
>> static inline bool io_recv_finish(struct io_kiocb *req,
>> struct io_async_msghdr *kmsg,
>> struct io_br_sel *sel, bool mshot_finished,
>> - unsigned issue_flags)
>> + unsigned issue_flags, size_t consumed)
>> {
>
> Not sure this is correct. If consumed is a size_t, then the comparison
> between ret > len is an unsigned comparison, and every error will then
> get clamped?
>
> Will need something like this folded in.
Can you check the current io_uring-7.3 or for-next tree and see if it
still fixes the issue?
--
Jens Axboe
prev parent reply other threads:[~2026-09-09 13:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 23:00 [PATCH 0/2] Fix return with MSG_TUNC overtruncating buffers Gabriel Krisman Bertazi
2026-09-02 23:00 ` [PATCH 1/2] io_uring/net: let io_recv_buf_select return the length of the buffer region Gabriel Krisman Bertazi
2026-09-02 23:00 ` [PATCH 2/2] io_uring/net: don't overconsume buffers when using MSG_TRUNC Gabriel Krisman Bertazi
2026-09-09 13:56 ` Jens Axboe
2026-09-09 13:58 ` Jens Axboe [this message]
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=01c58aa2-005c-49be-9d18-64d56d6fbb4b@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=krisman@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox