Skip to contentSkip to conversation

io_uring/net: ensure io_send() recycles buffers for -EAGAIN retry

PATCH New Jens Axboe 1 participant 1 message Jan 26 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/net: ensure io_send() recycles buffers for -EAGAIN retry

If io_send() is using bundles or ring provided buffers in general, then it must call io_kbuf_recycle() for the -EAGAIN case that ends up punting to polling. If not, a later send could potentially pick a later buffer and complete before the previous buffer, if space has freed up in the socket and it races with poll retry of the previous send.

Fixes a05d1f625c7a ("io_uring/net: support bundles for send")

---

io_uring/net.c +3 -1
index 519ea055b761..b1c3b86539ee 100644
@@ -673,8 +673,10 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
 	kmsg->msg.msg_flags = flags;
 	ret = sock_sendmsg(sock, &kmsg->msg);
 	if (ret < min_ret) {
-		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
+		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK)) {
+			io_kbuf_recycle(req, sel.buf_list, issue_flags);
 			return -EAGAIN;
+		}
 
 		if (ret > 0 && io_net_retry(sock, flags)) {
 			sr->len -= ret;
Signature · 1 line
Jens Axboe