]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:20 +0000 (15:37 -0500)
[ Upstream commit 18282100d7040614b553f1cad737cb689c04e2b9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/tcp.c

index ba36f558f144c6e542bb59cea94616499d9b05b0..f421cad69d8c94ecf39fd47a56b2593b282ba7db 100644 (file)
@@ -2821,9 +2821,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;
                                }