Skip to contentSkip to conversation

send/recv bundle fixes

PATCH New Jens Axboe 1 participant 4 messages Aug 8, 2024

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

cover send/recv bundle fixes

Hi,

Just three minor fixes for 6.11, all marked for stable as well. Two of them fix a missing REQ_F_NEED_CLEANUP being set for recv and send, and the last one fixes non-bundle sends potentially picking more than one buffer. Only bundle sends should do that.

Signature · 1 line
Jens Axboe
author maintainer
#1 lore raw

PATCH 1/3 io_uring/net: ensure expanded bundle recv gets marked for cleanup

If the iovec inside the kmsg isn't already allocated AND one gets expanded beyond the fixed size, then the request may not already have been marked for cleanup. Ensure that it is.

Fixes 2f9c9515bdfd ("io_uring/net: support bundles for recv")
---
 io_uring/net.c | 1 +
 1 file changed, 1 insertion(+)
io_uring/net.c +1 -0
index 594490a1389b..97a48408cec3 100644
@@ -1094,6 +1094,7 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
 		if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->free_iov) {
 			kmsg->free_iov_nr = ret;
 			kmsg->free_iov = arg.iovs;
+			req->flags |= REQ_F_NEED_CLEANUP;
 		}
 	} else {
 		void __user *buf;
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH 2/3 io_uring/net: ensure expanded bundle send gets marked for cleanup

In reply to Jens Axboe

If the iovec inside the kmsg isn't already allocated AND one gets expanded beyond the fixed size, then the request may not already have been marked for cleanup. Ensure that it is.

Fixes a05d1f625c7a ("io_uring/net: support bundles for send")
---
 io_uring/net.c | 1 +
 1 file changed, 1 insertion(+)
io_uring/net.c +1 -0
index 97a48408cec3..050bea5e7256 100644
@@ -623,6 +623,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
 		if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->free_iov) {
 			kmsg->free_iov_nr = ret;
 			kmsg->free_iov = arg.iovs;
+			req->flags |= REQ_F_NEED_CLEANUP;
 		}
 	}
 
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH 3/3 io_uring/net: don't pick multiple buffers for non-bundle send

In reply to Jens Axboe

If a send is issued marked with IOSQE_BUFFER_SELECT for selecting a buffer, unless it's a bundle, it should not select multiple buffers.

Fixes a05d1f625c7a ("io_uring/net: support bundles for send")
---
 io_uring/net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
io_uring/net.c +3 -2
index 050bea5e7256..d08abcca89cc 100644
@@ -601,17 +601,18 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
 			.iovs = &kmsg->fast_iov,
 			.max_len = INT_MAX,
 			.nr_iovs = 1,
-			.mode = KBUF_MODE_EXPAND,
 		};
 
 		if (kmsg->free_iov) {
 			arg.nr_iovs = kmsg->free_iov_nr;
 			arg.iovs = kmsg->free_iov;
-			arg.mode |= KBUF_MODE_FREE;
+			arg.mode = KBUF_MODE_FREE;
 		}
 
 		if (!(sr->flags & IORING_RECVSEND_BUNDLE))
 			arg.nr_iovs = 1;
+		else
+			arg.mode |= KBUF_MODE_EXPAND;
 
 		ret = io_buffers_select(req, &arg, issue_flags);
 		if (unlikely(ret < 0))
Signature · 1 line
2.43.0