<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/io_uring/kbuf.c, branch v6.17</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-08-28T11:48:34Z</updated>
<entry>
<title>io_uring/kbuf: always use READ_ONCE() to read ring provided buffer lengths</title>
<updated>2025-08-28T11:48:34Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-08-27T21:27:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=98b6fa62c84f2e129161e976a5b9b3cb4ccd117b'/>
<id>urn:sha1:98b6fa62c84f2e129161e976a5b9b3cb4ccd117b</id>
<content type='text'>
Since the buffers are mapped from userspace, it is prudent to use
READ_ONCE() to read the value into a local variable, and use that for
any other actions taken. Having a stable read of the buffer length
avoids worrying about it changing after checking, or being read multiple
times.

Similarly, the buffer may well change in between it being picked and
being committed. Ensure the looping for incremental ring buffer commit
stops if it hits a zero sized buffer, as no further progress can be made
at that point.

Fixes: ae98dbf43d75 ("io_uring/kbuf: add support for incremental buffer consumption")
Link: https://lore.kernel.org/io-uring/tencent_000C02641F6250C856D0C26228DE29A3D30A@qq.com/
Reported-by: Qingyue Zhang &lt;chunzhennn@qq.com&gt;
Reported-by: Suoxing Zhang &lt;aftern00n@qq.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: fix signedness in this_len calculation</title>
<updated>2025-08-27T14:39:44Z</updated>
<author>
<name>Qingyue Zhang</name>
<email>chunzhennn@qq.com</email>
</author>
<published>2025-08-27T11:43:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c64eff368ac676e8540344d27a3de47e0ad90d21'/>
<id>urn:sha1:c64eff368ac676e8540344d27a3de47e0ad90d21</id>
<content type='text'>
When importing and using buffers, buf-&gt;len is considered unsigned.
However, buf-&gt;len is converted to signed int when committing. This can
lead to unexpected behavior if the buffer is large enough to be
interpreted as a negative value. Make min_t calculation unsigned.

Fixes: ae98dbf43d75 ("io_uring/kbuf: add support for incremental buffer consumption")
Co-developed-by: Suoxing Zhang &lt;aftern00n@qq.com&gt;
Signed-off-by: Suoxing Zhang &lt;aftern00n@qq.com&gt;
Signed-off-by: Qingyue Zhang &lt;chunzhennn@qq.com&gt;
Link: https://lore.kernel.org/r/tencent_4DBB3674C0419BEC2C0C525949DA410CA307@qq.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: flag partial buffer mappings</title>
<updated>2025-06-26T18:17:48Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-06-26T18:17:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=178b8ff66ff827c41b4fa105e9aabb99a0b5c537'/>
<id>urn:sha1:178b8ff66ff827c41b4fa105e9aabb99a0b5c537</id>
<content type='text'>
A previous commit aborted mapping more for a non-incremental ring for
bundle peeking, but depending on where in the process this peeking
happened, it would not necessarily prevent a retry by the user. That can
create gaps in the received/read data.

Add struct buf_sel_arg-&gt;partial_map, which can pass this information
back. The networking side can then map that to internal state and use it
to gate retry as well.

Since this necessitates a new flag, change io_sr_msg-&gt;retry to a
retry_flags member, and store both the retry and partial map condition
in there.

Cc: stable@vger.kernel.org
Fixes: 26ec15e4b0c1 ("io_uring/kbuf: don't truncate end buffer for multiple buffer peeks")
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: don't truncate end buffer for multiple buffer peeks</title>
<updated>2025-06-13T17:01:49Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-06-13T17:01:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=26ec15e4b0c1d7b25214d9c0be1d50492e2f006c'/>
<id>urn:sha1:26ec15e4b0c1d7b25214d9c0be1d50492e2f006c</id>
<content type='text'>
If peeking a bunch of buffers, normally io_ring_buffers_peek() will
truncate the end buffer. This isn't optimal as presumably more data will
be arriving later, and hence it's better to stop with the last full
buffer rather than truncate the end buffer.

Cc: stable@vger.kernel.org
Fixes: 35c8711c8fc4 ("io_uring/kbuf: add helpers for getting/peeking multiple buffers")
Reported-by: Christian Mazakas &lt;christian.mazakas@gmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: limit legacy provided buffer lists to USHRT_MAX</title>
<updated>2025-06-03T21:32:44Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-06-03T13:42:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=607d09d1a01e9f29e91733e3a08b63ed240aacb2'/>
<id>urn:sha1:607d09d1a01e9f29e91733e3a08b63ed240aacb2</id>
<content type='text'>
The buffer ID for a provided buffer is an unsigned short, and hence
there can only be 64k added to any given buffer list before having
duplicate BIDs. Cap the legacy provided buffers at 64k in the list.
This is mostly to prevent silly stall reports from syzbot, which
likes to dump tons of buffers into a list and then have kernels with
lockdep and kasan churning through them and hitting long wait times
for buffer pruning at ring exit time.

Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring: finish IOU_OK -&gt; IOU_COMPLETE transition</title>
<updated>2025-05-21T14:41:16Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2025-05-08T20:48:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8bb9d6ccd36062d16baa707b759809e1f494017e'/>
<id>urn:sha1:8bb9d6ccd36062d16baa707b759809e1f494017e</id>
<content type='text'>
IOU_COMPLETE is more descriptive, in that it explicitly says that the
return value means "please post a completion for this request". This
patch completes the transition from IOU_OK to IOU_COMPLETE, replacing
existing IOU_OK users.

This is a purely mechanical change.

Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: unify legacy buf provision and removal</title>
<updated>2025-05-13T20:45:55Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2025-05-13T17:26:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b61bb1d9aa601ec393054a61be0a707a5bea928'/>
<id>urn:sha1:2b61bb1d9aa601ec393054a61be0a707a5bea928</id>
<content type='text'>
Combine IORING_OP_PROVIDE_BUFFERS and IORING_OP_REMOVE_BUFFERS
-&gt;issue(), so that we can deduplicate ring locking and list lookups.
This way we further reduce code for legacy provided buffers. Locking is
also separated from buffer related handling, which makes it a bit
simpler with label jumps.

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/f61af131622ad4337c2fb9f7c453d5b0102c7b90.1747150490.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: refactor __io_remove_buffers</title>
<updated>2025-05-13T20:45:55Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2025-05-13T17:26:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c724e801239ffc3714afe65cf6e721ddd04199d0'/>
<id>urn:sha1:c724e801239ffc3714afe65cf6e721ddd04199d0</id>
<content type='text'>
__io_remove_buffers used for two purposes, the first is removing
buffers for non ring based lists, which implies that it can be called
multiple times for the same list. And the second is for destroying
lists, which is not perfectly reentrable for ring based lists.

It's confusing, so just have a helper for the legacy pbuf buffer
removal, make sure it's not called for ring pbuf, and open code all ring
pbuf destruction into io_put_bl().

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/0ae416b099d311ad23f285cea02f2c94c8ae9a6c.1747150490.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: don't compute size twice on prep</title>
<updated>2025-05-13T20:45:55Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2025-05-13T17:26:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=52a05d0cf8f3b4569c525153132a90661c32fe11'/>
<id>urn:sha1:52a05d0cf8f3b4569c525153132a90661c32fe11</id>
<content type='text'>
The size in prep is calculated by io_provide_buffers_prep(), so remove
the recomputation a few lines after.

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/7c97206561b74fce245cb22449c6082d2e066844.1747150490.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>io_uring/kbuf: drop extra vars in io_register_pbuf_ring</title>
<updated>2025-05-13T20:45:55Z</updated>
<author>
<name>Pavel Begunkov</name>
<email>asml.silence@gmail.com</email>
</author>
<published>2025-05-13T17:26:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4e9fda29d66b06caf5c81b8acbe0a504effc73fb'/>
<id>urn:sha1:4e9fda29d66b06caf5c81b8acbe0a504effc73fb</id>
<content type='text'>
bl and free_bl variables in io_register_pbuf_ring() always point to the
same list since we started to reallocate the pre-existent list. Drop
free_bl.

Signed-off-by: Pavel Begunkov &lt;asml.silence@gmail.com&gt;
Link: https://lore.kernel.org/r/d45c3342d74c9030f99376c777a4b3d59089074d.1747150490.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
