FAILED: patch "[PATCH] io_uring/kbuf: support min length left for incremental" failed to apply to 6.18-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 7deba791ad495ce1d7921683f4f7d1190fa210d1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051232-kindred-spooky-37ac@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7deba791ad495ce1d7921683f4f7d1190fa210d1 Mon Sep 17 00:00:00 2001
From: Martin Michaelis <[email protected]>
Date: Thu, 23 Apr 2026 15:54:11 -0600
Subject: [PATCH] io_uring/kbuf: support min length left for incremental
buffers
Incrementally consumed buffer rings are generally fully consumed, but it's quite possible that the application has a minimum size it needs to meet to avoid truncation. Currently that minimum limit is 1 byte, but this should be a setting that is the hands of the application. For recvmsg multishot, a prime use case for incrementally consumed buffers, the application may get spurious -EFAULT returned at the end of an incrementally consumed buffer, as less space is available than the headers need.
Grab a u32 field in struct io_uring_buf_reg, which the application can use to inform the kernel of the minimum size that should be available in an incrementally consumed buffer. If less than that is available, the current buffer is fully processed and the next one will be picked.
include/uapi/linux/io_uring.h +2 -1
@@ -905,7 +905,8 @@ struct io_uring_buf_reg {__u32 ring_entries;__u16 bgid;__u16 flags; -__u64 resv[3 ]; +__u32 min_left; +__u32 resv[5 ]; };/* argument for IORING_REGISTER_PBUF_STATUS */
io_uring/kbuf.c +7 -1
@@ -47,7 +47,7 @@ static bool io_kbuf_inc_commit(struct io_buffer_list *bl, int len) this_len =min_t (u32, len, buf_len); buf_len -= this_len;/* Stop looping for invalid buffer length of 0 */ -if (buf_len || !this_len) { +if (buf_len > bl->min_left_sub_one || !this_len) {WRITE_ONCE (buf->addr,READ_ONCE (buf->addr) + this_len);WRITE_ONCE (buf->len, buf_len);return false;
@@ -637,6 +637,10 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)if (reg.ring_entries >=65536 )return -EINVAL ; +/* minimum left byte count is a property of incremental buffers */ +if (!(reg.flags &IOU_PBUF_RING_INC ) && reg.min_left) +return -EINVAL ; + bl =io_buffer_get_list (ctx, reg.bgid);if (bl) {/* if mapped buffer ring OR classic exists, don't allow */
@@ -683,6 +687,8 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) bl->mask = reg.ring_entries -1 ; bl->flags |=IOBL_BUF_RING ; bl->buf_ring = br; +if (reg.min_left) + bl->min_left_sub_one = reg.min_left -1 ;if (reg.flags &IOU_PBUF_RING_INC ) bl->flags |=IOBL_INC ; ret =io_buffer_add_list (ctx, bl, reg.bgid);
io_uring/kbuf.h +7 -0
@@ -32,6 +32,13 @@ struct io_buffer_list {__u16 flags; +/* +* minimum required amount to be left to reuse an incrementally +* consumed buffer. If less than this is left at consumption time, +* buffer is done and head is incremented to the next buffer. +*/ +__u32 min_left_sub_one; +struct io_mapped_region region; };
Quoted 6 lines · On 5/12/26 6:41 AM, [email protected] wrote:
The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Quoted 8 lines
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkoutFETCH_HEAD
git cherry-pick -x7deba791ad495ce1d7921683f4f7d1190fa210d1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051232-kindred-spooky-37ac@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..
Here's one for 6.18-stable.
Signature · 1 line
Jens Axboe
From ae165fed72f9686aeb04766a15459807114a5023 Mon Sep 17 00:00:00 2001
From: Martin Michaelis <[email protected]>
Date: Thu, 23 Apr 2026 15:54:11 -0600
Subject: [PATCH 2/2] io_uring/kbuf: support min length left for incremental
buffers
Commit 7deba791ad495ce1d7921683f4f7d1190fa210d1 upstream.
Incrementally consumed buffer rings are generally fully consumed, but it's quite possible that the application has a minimum size it needs to meet to avoid truncation. Currently that minimum limit is 1 byte, but this should be a setting that is the hands of the application. For recvmsg multishot, a prime use case for incrementally consumed buffers, the application may get spurious -EFAULT returned at the end of an incrementally consumed buffer, as less space is available than the headers need.
Grab a u32 field in struct io_uring_buf_reg, which the application can use to inform the kernel of the minimum size that should be available in an incrementally consumed buffer. If less than that is available, the current buffer is fully processed and the next one will be picked.
--- include/uapi/linux/io_uring.h | 3 ++- io_uring/kbuf.c | 12 +++++++++--- io_uring/kbuf.h | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-)
include/uapi/linux/io_uring.h +2 -1
@@ -864,7 +864,8 @@ struct io_uring_buf_reg {__u32 ring_entries;__u16 bgid;__u16 flags; -__u64 resv[3 ]; +__u32 min_left; +__u32 resv[5 ]; };/* argument for IORING_REGISTER_PBUF_STATUS */
io_uring/kbuf.c +9 -3
@@ -47,9 +47,9 @@ static bool io_kbuf_inc_commit(struct io_buffer_list *bl, int len) this_len =min_t (u32, len, buf_len); buf_len -= this_len;/* Stop looping for invalid buffer length of 0 */ -if (buf_len || !this_len) { - buf->addr =READ_ONCE (buf->addr) + this_len; - buf->len = buf_len; +if (buf_len > bl->min_left_sub_one || !this_len) { +WRITE_ONCE (buf->addr,READ_ONCE (buf->addr) + this_len); +WRITE_ONCE (buf->len, buf_len);return false; } buf->len =0 ;
@@ -637,6 +637,10 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)if (reg.ring_entries >=65536 )return -EINVAL ; +/* minimum left byte count is a property of incremental buffers */ +if (!(reg.flags &IOU_PBUF_RING_INC ) && reg.min_left) +return -EINVAL ; + bl =io_buffer_get_list (ctx, reg.bgid);if (bl) {/* if mapped buffer ring OR classic exists, don't allow */
@@ -684,6 +688,8 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) bl->mask = reg.ring_entries -1 ; bl->flags |=IOBL_BUF_RING ; bl->buf_ring = br; +if (reg.min_left) + bl->min_left_sub_one = reg.min_left -1 ;if (reg.flags &IOU_PBUF_RING_INC ) bl->flags |=IOBL_INC ; ret =io_buffer_add_list (ctx, bl, reg.bgid);
io_uring/kbuf.h +7 -0
@@ -34,6 +34,13 @@ struct io_buffer_list {__u16 flags; +/* +* minimum required amount to be left to reuse an incrementally +* consumed buffer. If less than this is left at consumption time, +* buffer is done and head is incremented to the next buffer. +*/ +__u32 min_left_sub_one; +struct io_mapped_region region; };
Signature · 1 line
2.53.0
Greg KH
maintainerQuoted 9 lines · Jens Axboe
Quoted 8 lines · On 5/12/26 6:41 AM, [email protected] wrote:
The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.To reproduce the conflict and resubmit, you may use the following commands:
Quoted 8 lines
Quoted 6 lines
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkoutFETCH_HEAD
git cherry-pick -x7deba791ad495ce1d7921683f4f7d1190fa210d1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051232-kindred-spooky-37ac@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..Here's one for 6.18-stable.
Both n ow applied, thanks.
greg k-h