linux/net/sunrpc
Daniel Borkmann 5d8254e012 net, sunrpc: Remap EPERM in case of connection failure in xs_tcp_setup_socket
commit 626dfed5fa upstream.

When using a BPF program on kernel_connect(), the call can return -EPERM. This
causes xs_tcp_setup_socket() to loop forever, filling up the syslog and causing
the kernel to potentially freeze up.

Neil suggested:

  This will propagate -EPERM up into other layers which might not be ready
  to handle it. It might be safer to map EPERM to an error we would be more
  likely to expect from the network system - such as ECONNREFUSED or ENETDOWN.

ECONNREFUSED as error seems reasonable. For programs setting a different error
can be out of reach (see handling in 4fbac77d2d) in particular on kernels
which do not have f10d059661 ("bpf: Make BPF_PROG_RUN_ARRAY return -err
instead of allow boolean"), thus given that it is better to simply remap for
consistent behavior. UDP does handle EPERM in xs_udp_send_request().

Fixes: d74bad4e74 ("bpf: Hooks for sys_connect")
Fixes: 4fbac77d2d ("bpf: Hooks for sys_bind")
Co-developed-by: Lex Siegel <usiegl00@gmail.com>
Signed-off-by: Lex Siegel <usiegl00@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Neil Brown <neilb@suse.de>
Cc: Trond Myklebust <trondmy@kernel.org>
Cc: Anna Schumaker <anna@kernel.org>
Link: https://github.com/cilium/cilium/issues/33395
Link: https://lore.kernel.org/bpf/171374175513.12877.8993642908082014881@noble.neil.brown.name
Link: https://patch.msgid.link/9069ec1d59e4b2129fc23433349fd5580ad43921.1720075070.git.daniel@iogearbox.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Hugo SIMELIERE <hsimeliere.opensource@witekio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-12 11:07:53 +02:00
..
auth_gss gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey 2024-08-19 05:44:58 +02:00
xprtrdma xprtrdma: Fix rpcrdma_reqs_reset() 2024-08-19 05:45:03 +02:00
addr.c net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() 2024-03-26 18:21:33 -04:00
auth_null.c
auth_unix.c
auth.c sunrpc: fix expiry of auth creds 2022-08-25 11:40:05 +02:00
backchannel_rqst.c SUNRPC: Reinitialise the backchannel request buffers before reuse 2022-08-25 11:40:05 +02:00
cache.c SUNRPC: improve error response to over-size gss credential 2021-09-03 13:38:11 -04:00
clnt.c SUNRPC: avoid soft lockup when transmitting UDP to reachable server. 2024-08-19 05:45:03 +02:00
debugfs.c NFS Client Updates for Linux 5.15 2021-09-04 10:25:26 -07:00
fail.h SUNRPC: Server-side disconnect injection 2021-08-20 13:50:33 -04:00
Kconfig SUNRPC: remove RC4-HMAC-MD5 support from KerberosV 2020-09-11 14:39:15 +10:00
Makefile sunrpc: Create a sunrpc directory under /sys/kernel/ 2021-07-08 14:03:23 -04:00
netns.h
rpc_pipe.c fsnotify: fix fsnotify hooks in pseudo filesystems 2022-02-01 17:27:01 +01:00
rpcb_clnt.c SUNRPC: Add an IS_ERR() check back to where it was 2023-11-28 16:56:21 +00:00
sched.c SUNRPC: Fix a race to wake a sync task 2024-08-19 05:45:39 +02:00
socklib.c skb_copy_and_csum_bits(): don't bother with the last argument 2020-08-20 15:45:13 -04:00
socklib.h
stats.c sunrpc: use the struct net as the svc proc private 2024-09-04 13:23:30 +02:00
sunrpc_syms.c sunrpc: add IDs to multipath 2021-07-08 14:03:23 -04:00
sunrpc.h Replace HTTP links with HTTPS ones: NFS, SUNRPC, and LOCKD clients 2020-09-21 10:21:10 -04:00
svc_xprt.c sunrpc: exclude from freezer when waiting for requests: 2024-06-16 13:39:55 +02:00
svc.c sunrpc: pass in the sv_stats struct through svc_create_pooled 2024-09-04 13:23:30 +02:00
svcauth_unix.c sunrpc: only free unix grouplist after RCU settles 2023-04-13 16:48:19 +02:00
svcauth.c SUNRPC: Add svc_rqst::rq_auth_stat 2021-08-10 14:18:35 -04:00
svcsock.c nfsd: fix double fget() bug in __write_ports_addfd() 2024-04-10 16:19:28 +02:00
sysctl.c net/sunrpc: fix useless comparison in proc_do_xprt() 2020-11-08 16:28:25 -05:00
sysfs.c SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed 2022-11-10 18:15:26 +01:00
sysfs.h SUNRPC: take a xprt offline using sysfs 2021-07-08 14:03:24 -04:00
timer.c
xdr.c NFSD: Refactor common code out of dirlist helpers 2024-04-10 16:19:17 +02:00
xprt.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-05-18 10:26:57 +02:00
xprtmultipath.c SUNRPC: Fix a suspicious RCU usage warning 2024-02-23 08:54:40 +01:00
xprtsock.c net, sunrpc: Remap EPERM in case of connection failure in xs_tcp_setup_socket 2024-09-12 11:07:53 +02:00