opnsense-src/sys/rpc
Mark Johnston 30cfefbaba rpcsec_tls: Avoid a socket reference underflow in rpctls_server()
The upcall_sockets tree owns a ref on any resident socket.  When a
socket is removed after a TLS handshake failure, rpctls_rpc_failed()
thus calls soclose().

rpctls_server() does not acquire an extra ref to compensate for this.
So, if the upcall fails, e.g., because rpc.tlsservd is not running,
we'll call soclose() to drop the reference, but this effectively
releases the xprt layer's reference.

Fix the problem by explicitly acquiring a socket reference when adding
a socket to the upcall tree.

Approved by:	so
Security:	FreeBSD-EN-26:17.rpcsec_tls
PR:		289734
Reviewed by:	rmacklem, glebius
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57555

(cherry picked from commit fc7993cf2d6ddba9f94683565838bf8fabc0145c)
(cherry picked from commit f3b14134dec11c2f09980f25c4c60accbfea0f1e)
2026-07-06 10:29:20 +02:00
..
rpcsec_gss kgss: remove KGSS_VNET_* macros family 2026-04-27 09:11:51 -07:00
rpcsec_tls rpcsec_tls: Avoid a socket reference underflow in rpctls_server() 2026-07-06 10:29:20 +02:00
auth.h sys/rpc: Define AUTH_SYS_MAX_{GROUPS,HOSTNAME} 2025-10-16 18:57:45 +02:00
auth_none.c xdr: provide x_putmbuf method for kernel XDR 2025-02-01 01:00:25 -08:00
auth_unix.c xdr: provide x_putmbuf method for kernel XDR 2025-02-01 01:00:25 -08:00
authunix_prot.c sys/rpc: UNIX auth: Style: Remove unnecessary headers, minor changes 2025-10-16 18:57:46 +02:00
clnt.h krpc: add kernel side client over netlink(4) 2025-02-01 01:00:25 -08:00
clnt_bck.c clnt_bck.c: Delete a couple of old diagnostic printfs 2026-04-07 17:54:18 -07:00
clnt_dg.c
clnt_nl.c krpc/clnt_nl: unregister the netlink group, when client is destroyed 2025-02-05 10:09:06 -08:00
clnt_nl.h krpc: add kernel side client over netlink(4) 2025-02-01 01:00:25 -08:00
clnt_rc.c clnt_rc.c: Fix the case where a TLS handshake fails 2025-07-18 17:39:08 -07:00
clnt_stat.h
clnt_vc.c rpcsec_tls/client: API refactoring between kernel and rpc.tlsclntd(8) 2025-02-01 01:00:27 -08:00
getnetconfig.c
krpc.h krpc/clnt_nl: filter RPC replies on vnet 2025-02-01 11:27:22 -08:00
netconfig.h
nettype.h
pmap_prot.h
replay.c
replay.h
rpc.h
rpc_callmsg.c
rpc_com.h
rpc_generic.c krpc: add kernel side client over netlink(4) 2025-02-01 01:00:25 -08:00
rpc_msg.h
rpc_prot.c
rpcb_clnt.c krpc: let the kernel talk to the rpcbind(8) service via netlink(4) 2025-02-01 01:00:26 -08:00
rpcb_clnt.h
rpcb_prot.c
rpcb_prot.h
rpcm_subs.h
rpcsec_gss.h
rpcsec_tls.h rpcsec_tls: cleanup the rpctls_syscall() 2025-02-01 01:00:28 -08:00
svc.c
svc.h rpcsec_tls/server: API refactoring between kernel and rpc.tlsservd(8) 2025-02-01 01:00:27 -08:00
svc_auth.c kern: rename crsetgroups_fallback, document it in ucred(9) 2025-07-31 19:50:48 -05:00
svc_auth.h
svc_auth_unix.c sys/rpc: UNIX auth: Do not log on bogus AUTH_SYS messages 2025-10-16 18:57:46 +02:00
svc_dg.c xdr: provide x_putmbuf method for kernel XDR 2025-02-01 01:00:25 -08:00
svc_generic.c
svc_vc.c rpc: Improve socket locking in svc_vc_accept() 2026-03-31 15:57:27 +00:00
types.h
xdr.h xdr: provide x_putmbuf method for kernel XDR 2025-02-01 01:00:25 -08:00