Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: preserve recvmmsg count after timeout copyout failure
@ 2026-12-05  5:42 Shawn Shao
  2026-12-05  5:48 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn Shao @ 2026-12-05  5:42 UTC (permalink / raw)
  To: edumazet, kuniyu, pabeni, willemb; +Cc: davem, kuba, horms, netdev


__sys_recvmmsg() replaces a positive message count with -EFAULT when it
cannot copy the remaining timeout back to userspace. The datagrams have
already been dequeued and copied to userspace at that point, so the error
hides completed receives from the caller.

Keep the received count when the optional timeout copyout fails.

Tested on x86_64 with QEMU TCG. A read-only timeout mapping receives two
datagrams and returns 2; writable, PROT_NONE, empty-queue, NULL-timeout,
and pselect controls pass.

Link: https://gist.github.com/shaos26/d697e44ff0f9bd801f61f2ce00a2dd51
Fixes: a2e2725541fa ("net: Introduce recvmmsg socket syscall")
Signed-off-by: Shawn Shao <shawnq1@163.com>
---
 net/socket.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 08658a9b8065d..02b7e813c902c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3151,11 +3151,11 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg,
 	if (datagrams <= 0)
 		return datagrams;
 
-	if (timeout && put_timespec64(&timeout_sys, timeout))
-		datagrams = -EFAULT;
-
-	if (timeout32 && put_old_timespec32(&timeout_sys, timeout32))
-		datagrams = -EFAULT;
+	/* The datagrams are already consumed; preserve their count on copyout. */
+	if (timeout)
+		put_timespec64(&timeout_sys, timeout);
+	if (timeout32)
+		put_old_timespec32(&timeout_sys, timeout32);
 
 	return datagrams;
 }
-- 
2.34.1


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

* Re: [PATCH] net: preserve recvmmsg count after timeout copyout failure
  2026-12-05  5:42 [PATCH] net: preserve recvmmsg count after timeout copyout failure Shawn Shao
@ 2026-12-05  5:48 ` netdev-bot+sinfo
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-12-05  5:48 UTC (permalink / raw)
  To: Shawn Shao; +Cc: edumazet, kuniyu, pabeni, willemb, davem, kuba, horms, netdev

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  5:42 [PATCH] net: preserve recvmmsg count after timeout copyout failure Shawn Shao
2026-12-05  5:48 ` netdev-bot+sinfo

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