* [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT @ 2026-07-26 22:28 ` Jens Axboe 2026-07-27 0:12 ` Gabriel Krisman Bertazi 2026-07-27 14:04 ` Nitesh Shetty 0 siblings, 2 replies; 3+ messages in thread From: Jens Axboe @ 2026-07-26 22:28 UTC (permalink / raw) To: io-uring; +Cc: Sung Keum io_ring_buffers_peek() builds an iovec array from provided buffers, and that in turn can be handed off to a lower level provider. Be prudent and cap the total size to MAX_RW_COUNT, which is the Linux default for how much IO do to in a single call. No bugs here, but it's a good preventative measure to avoid truncation issues. Signed-off-by: Jens Axboe <axboe@kernel.dk> --- diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index de0129bceaba..1cf5be62bb65 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -266,6 +266,9 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg, if (unlikely(!nr_avail)) return -ENOBUFS; + /* MAX_RW_COUNT is the universal Linux per-call IO maximum */ + arg->max_len = min_t(size_t, arg->max_len, MAX_RW_COUNT); + buf = io_ring_head_to_buf(br, head, bl->mask); if (arg->max_len) { u32 len = READ_ONCE(buf->len); @@ -295,7 +298,7 @@ static int io_ring_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg, /* set it to max, if not set, so we can use it unconditionally */ if (!arg->max_len) - arg->max_len = INT_MAX; + arg->max_len = MAX_RW_COUNT; req->buf_index = READ_ONCE(buf->bid); do { -- Jens Axboe ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT 2026-07-26 22:28 ` [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT Jens Axboe @ 2026-07-27 0:12 ` Gabriel Krisman Bertazi 2026-07-27 14:04 ` Nitesh Shetty 1 sibling, 0 replies; 3+ messages in thread From: Gabriel Krisman Bertazi @ 2026-07-27 0:12 UTC (permalink / raw) To: Jens Axboe, io-uring; +Cc: Sung Keum Jens Axboe <axboe@kernel.dk> writes: > io_ring_buffers_peek() builds an iovec array from provided buffers, and > that in turn can be handed off to a lower level provider. Be prudent and > cap the total size to MAX_RW_COUNT, which is the Linux default for how > much IO do to in a single call. > > No bugs here, but it's a good preventative measure to avoid truncation > issues. > > Signed-off-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT 2026-07-26 22:28 ` [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT Jens Axboe 2026-07-27 0:12 ` Gabriel Krisman Bertazi @ 2026-07-27 14:04 ` Nitesh Shetty 1 sibling, 0 replies; 3+ messages in thread From: Nitesh Shetty @ 2026-07-27 14:04 UTC (permalink / raw) To: Jens Axboe; +Cc: io-uring, Sung Keum [-- Attachment #1: Type: text/plain, Size: 474 bytes --] On 26/07/26 04:28PM, Jens Axboe wrote: >io_ring_buffers_peek() builds an iovec array from provided buffers, and >that in turn can be handed off to a lower level provider. Be prudent and >cap the total size to MAX_RW_COUNT, which is the Linux default for how >much IO do to in a single call. > >No bugs here, but it's a good preventative measure to avoid truncation >issues. > >Signed-off-by: Jens Axboe <axboe@kernel.dk> > Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com> [-- Attachment #2: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-27 14:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20260727140454epcas5p1a2306b5a87d2ff6d299e89b0af320213@epcas5p1.samsung.com>
2026-07-26 22:28 ` [PATCH] io_uring/kbuf: cap buffer selection length at MAX_RW_COUNT Jens Axboe
2026-07-27 0:12 ` Gabriel Krisman Bertazi
2026-07-27 14:04 ` Nitesh Shetty
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox