]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: devmem: expose tcp_recvmsg_locked errors
authorStanislav Fomichev <sdf@fomichev.me>
Wed, 10 Sep 2025 16:24:29 +0000 (09:24 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 12 Sep 2025 01:59:57 +0000 (18:59 -0700)
tcp_recvmsg_dmabuf can export the following errors:
- EFAULT when linear copy fails
- ETOOSMALL when cmsg put fails
- ENODEV if one of the frags is readable
- ENOMEM on xarray failures

But they are all ignored and replaced by EFAULT in the caller
(tcp_recvmsg_locked). Expose real error to the userspace to
add more transparency on what specifically fails.

In non-devmem case (skb_copy_datagram_msg) doing `if (!copied)
copied=-EFAULT` is ok because skb_copy_datagram_msg can return only EFAULT.

Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250910162429.4127997-1-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/tcp.c

index 588932c3cf1d549973ccfa095a8de1be87421a63..9c576dc9a1f7ccb8541f6994361d04c0e0306bd1 100644 (file)
@@ -2818,9 +2818,9 @@ found_ok_skb:
 
                                err = tcp_recvmsg_dmabuf(sk, skb, offset, msg,
                                                         used);
-                               if (err <= 0) {
+                               if (err < 0) {
                                        if (!copied)
-                                               copied = -EFAULT;
+                                               copied = err;
 
                                        break;
                                }