mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo
@ 2026-12-05 10:48 Hang Zhengyang
  2026-12-05 10:48 ` [PATCH 1/2] io_uring/net: restore msg_controllen on compat sendmsg retry Hang Zhengyang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hang Zhengyang @ 2026-12-05 10:48 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, Keith Busch, Nicholas Carlini, io-uring, linux-kernel

Two unrelated fixes. Patch 1 makes a retried SENDMSG or SENDMSG_ZC with
a control message work on a compat ring. Patch 2 makes the fdinfo SQ
dump of an SQE_MIXED ring list every SQE and nothing past the tail.

Tested in an x86_64 KVM guest on io_uring-7.4: the 32-bit sendmsg tests
and the fdinfo tests fail without the series and pass with it, and the
liburing tests show no new failures. The patch 1 test also fails on
6.12.120 and 6.6.163.

I used Claude Code to find the issues, write the patches and run the
tests. I reviewed the patches.

Hang Zhengyang (2):
  io_uring/net: restore msg_controllen on compat sendmsg retry
  io_uring/fdinfo: don't skip the SQE after a 128-byte one

 io_uring/fdinfo.c | 1 -
 io_uring/net.c    | 8 ++++++++
 2 files changed, 8 insertions(+), 1 deletion(-)


base-commit: 7e3dc305a86e40ce1f9cd926ecd06d339468f5cb
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] io_uring/net: restore msg_controllen on compat sendmsg retry
  2026-12-05 10:48 [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Hang Zhengyang
@ 2026-12-05 10:48 ` Hang Zhengyang
  2026-12-05 10:48 ` [PATCH 2/2] io_uring/fdinfo: don't skip the SQE after a 128-byte one Hang Zhengyang
  2026-12-05 14:04 ` [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Hang Zhengyang @ 2026-12-05 10:48 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, Keith Busch, Nicholas Carlini, io-uring,
	linux-kernel, stable

On a compat ring, a retried IORING_OP_SENDMSG or IORING_OP_SENDMSG_ZC
with a control message can fail with -EINVAL.

The compat cmsg conversion in ____sys_sendmsg() replaces msg_controllen
with the native length, 24 instead of 16 for one SCM_RIGHTS fd. On a
retry, io_uring restores msg_control but not msg_controllen, so the
conversion runs past the end of the user's control buffer.

Save msg_controllen before each attempt and restore it after.

Fixes: cac9e4418f4c ("io_uring/net: save msghdr->msg_control for retries")
Fixes: 4fe82aedeb8a ("io_uring/net: restore msg_control on sendzc retry")
Cc: stable@vger.kernel.org
Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>
---
 io_uring/net.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/io_uring/net.c b/io_uring/net.c
index b0d508b772ce..0976e25b9d80 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -549,6 +549,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
 	struct io_async_msghdr *kmsg = req->async_data;
 	struct socket *sock;
 	unsigned flags;
+	size_t controllen;
 	int min_ret = 0;
 	int ret;
 
@@ -567,8 +568,11 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
 		min_ret = iov_iter_count(&kmsg->msg.msg_iter);
 
 	kmsg->msg.msg_control_user = sr->msg_control;
+	controllen = kmsg->msg.msg_controllen;
 
 	ret = __sys_sendmsg_sock(sock, &kmsg->msg, flags);
+	/* compat cmsg conversion changes it, restore it for a retry */
+	kmsg->msg.msg_controllen = controllen;
 
 	if (ret < min_ret) {
 		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
@@ -1602,8 +1606,12 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
 		kmsg->msg.msg_flags = msg_flags;
 		ret = sock_sendmsg(sock, &kmsg->msg);
 	} else {
+		size_t controllen = kmsg->msg.msg_controllen;
+
 		kmsg->msg.msg_control_user = sr->msg_control;
 		ret = __sys_sendmsg_sock(sock, &kmsg->msg, msg_flags);
+		/* compat cmsg conversion changes it, restore it for a retry */
+		kmsg->msg.msg_controllen = controllen;
 	}
 
 	if (unlikely(ret < min_ret)) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] io_uring/fdinfo: don't skip the SQE after a 128-byte one
  2026-12-05 10:48 [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Hang Zhengyang
  2026-12-05 10:48 ` [PATCH 1/2] io_uring/net: restore msg_controllen on compat sendmsg retry Hang Zhengyang
@ 2026-12-05 10:48 ` Hang Zhengyang
  2026-12-05 14:04 ` [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Hang Zhengyang @ 2026-12-05 10:48 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, Keith Busch, Nicholas Carlini, io-uring,
	linux-kernel, stable

For a 128-byte SQE on an IORING_SETUP_SQE_MIXED ring, the SQ dump in
fdinfo increments both i and sq_head, so it moves on three slots instead
of two. It then skips the next SQE, and the dump goes past the SQ tail.

The i++ was added to stop the dump at the tail, but the sq_head++ that
skipped the second half was kept. Drop it.

Fixes: 101e596e7404 ("io_uring/fdinfo: cap SQ iteration at max SQ entries")
Fixes: b59efde9e6c1 ("io_uring/fdinfo: fix SQE_MIXED SQE displaying")
Cc: stable@vger.kernel.org # v7.0+
Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>
---
 io_uring/fdinfo.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c
index 46e64b041360..bd7f80474144 100644
--- a/io_uring/fdinfo.c
+++ b/io_uring/fdinfo.c
@@ -125,7 +125,6 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
 					sq_idx);
 				break;
 			}
-			sq_head++;
 			i++;
 			sqe128 = true;
 		}
-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo
  2026-12-05 10:48 [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Hang Zhengyang
  2026-12-05 10:48 ` [PATCH 1/2] io_uring/net: restore msg_controllen on compat sendmsg retry Hang Zhengyang
  2026-12-05 10:48 ` [PATCH 2/2] io_uring/fdinfo: don't skip the SQE after a 128-byte one Hang Zhengyang
@ 2026-12-05 14:04 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-12-05 14:04 UTC (permalink / raw)
  To: Hang Zhengyang
  Cc: Pavel Begunkov, Keith Busch, Nicholas Carlini, io-uring, linux-kernel


On Sat, 05 Dec 2026 10:48:52 +0000, Hang Zhengyang wrote:
> Two unrelated fixes. Patch 1 makes a retried SENDMSG or SENDMSG_ZC with
> a control message work on a compat ring. Patch 2 makes the fdinfo SQ
> dump of an SQE_MIXED ring list every SQE and nothing past the tail.
> 
> Tested in an x86_64 KVM guest on io_uring-7.4: the 32-bit sendmsg tests
> and the fdinfo tests fail without the series and pass with it, and the
> liburing tests show no new failures. The patch 1 test also fails on
> 6.12.120 and 6.6.163.
> 
> [...]

Applied, thanks!

[1/2] io_uring/net: restore msg_controllen on compat sendmsg retry
      commit: eab4ad4e924e1d46de4c89e70d99f5b0c7cce590
[2/2] io_uring/fdinfo: don't skip the SQE after a 128-byte one
      commit: 416f1d31a8acea8b45b5da50e78147b83ccf63a8

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-05 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-05 10:48 [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Hang Zhengyang
2026-12-05 10:48 ` [PATCH 1/2] io_uring/net: restore msg_controllen on compat sendmsg retry Hang Zhengyang
2026-12-05 10:48 ` [PATCH 2/2] io_uring/fdinfo: don't skip the SQE after a 128-byte one Hang Zhengyang
2026-12-05 14:04 ` [PATCH 0/2] io_uring: fix compat sendmsg retry and SQE_MIXED fdinfo Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®