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
auth_unix.c
authunix_prot.c sys/rpc: UNIX auth: Style: Remove unnecessary headers, minor changes 2025-10-16 18:57:46 +02:00
clnt.h
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
clnt_nl.h
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
getnetconfig.c
krpc.h
netconfig.h
nettype.h
pmap_prot.h
replay.c
replay.h
rpc.h
rpc_callmsg.c
rpc_com.h
rpc_generic.c
rpc_msg.h
rpc_prot.c
rpcb_clnt.c
rpcb_clnt.h
rpcb_prot.c
rpcb_prot.h
rpcm_subs.h
rpcsec_gss.h
rpcsec_tls.h
svc.c
svc.h
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
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