]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
io_uring/net: commit partial buffers on retry
authorJens Axboe <axboe@kernel.dk>
Tue, 12 Aug 2025 14:30:11 +0000 (08:30 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:11 +0000 (16:28 +0200)
commit3b53dc1c641f2884d4750fc25aaf6c36b90db606
treeb9a4273926f2f7d02efaa5aa378b196728fb5236
parentccef5ee4adf56472aa26bdd1f821a6d0cd06089a
io_uring/net: commit partial buffers on retry

Commit 41b70df5b38bc80967d2e0ed55cc3c3896bba781 upstream.

Ring provided buffers are potentially only valid within the single
execution context in which they were acquired. io_uring deals with this
and invalidates them on retry. But on the networking side, if
MSG_WAITALL is set, or if the socket is of the streaming type and too
little was processed, then it will hang on to the buffer rather than
recycle or commit it. This is problematic for two reasons:

1) If someone unregisters the provided buffer ring before a later retry,
   then the req->buf_list will no longer be valid.

2) If multiple sockers are using the same buffer group, then multiple
   receives can consume the same memory. This can cause data corruption
   in the application, as either receive could land in the same
   userspace buffer.

Fix this by disallowing partial retries from pinning a provided buffer
across multiple executions, if ring provided buffers are used.

Cc: stable@vger.kernel.org
Reported-by: pt x <superman.xpt@gmail.com>
Fixes: c56e022c0a27 ("io_uring: add support for user mapped provided buffer ring")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/net.c