mirror-linux/Documentation/netlink/specs
Chuck Lever 6b22d433aa net/handshake: Pass negative errno through handshake_complete()
handshake_complete() declares status as unsigned int and
tls_handshake_done() negates that value (-status) before handing
it to the TLS consumer. Consumers match on negative errno
constants -- xs_tls_handshake_done() has

	switch (status) {
	case 0:
	case -EACCES:
	case -ETIMEDOUT:
		lower_transport->xprt_err = status;
		break;
	default:
		lower_transport->xprt_err = -EACCES;
	}

so the API as designed expects callers to pass positive errno
values that the tlshd shim then negates.

Three internal callers in handshake_nl_accept_doit(), the
net-exit drain, and a kunit test follow kernel convention and
pass negative errnos -- -EIO, -ETIMEDOUT, -ETIMEDOUT. The
implicit conversion to unsigned int turns -ETIMEDOUT into
0xFFFFFF92; the subsequent -status in tls_handshake_done()
wraps back to 110, the consumer's switch falls through, and
the xprt reports -EACCES on what should be -ETIMEDOUT or -EIO.

Fix the API rather than the call sites. The natural kernel
convention is negative errno in, negative errno out. Change
handshake_complete() and hp_done to take int status, drop the
negation in tls_handshake_done(), and negate once in
handshake_nl_done_doit() where status arrives from the wire
as an unsigned netlink attribute. The three internal callers
were already correct under that convention and need no change.

At the same wire boundary, declare MAX_ERRNO as the netlink
policy upper bound for HANDSHAKE_A_DONE_STATUS. Attribute
validation rejects out-of-range values before
handshake_nl_done_doit() runs, and negating a bounded u32 there
stays within int range -- closing the UBSAN-visible signed-
integer overflow that an unconstrained u32 would invoke.

Fixes: 3b3009ea8a ("net/handshake: Create a NETLINK service for handling handshake requests")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Link: https://patch.msgid.link/20260525-handshake-file-pin-v3-3-66c616906ead@oracle.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-05-28 13:35:31 +02:00
..
binder.yaml netlink: specs: binder: replace underscores with dashes in names 2025-08-21 16:49:38 +02:00
conntrack.yaml ynl: fix schema check errors 2025-11-28 19:53:20 -08:00
dev-energymodel.yaml PM: EM: Add dump to get-perf-domains in the EM YNL spec 2026-01-09 21:44:46 +01:00
devlink.yaml devlink: Add resource scope filtering to resource dump 2026-04-08 19:55:39 -07:00
dpll.yaml dpll: add frequency monitoring to netlink spec 2026-04-03 16:48:01 -07:00
drm_ras.yaml drm/ras: Introduce the DRM RAS infrastructure over generic netlink 2026-03-05 19:38:55 -05:00
ethtool.yaml net: ethtool: add ethtool COALESCE_RX_CQE_FRAMES/NSECS 2026-03-18 20:01:10 -07:00
fou.yaml fou: Don't allow 0 for FOU_ATTR_IPPROTO. 2026-01-17 16:00:24 -08:00
handshake.yaml net/handshake: Pass negative errno through handshake_complete() 2026-05-28 13:35:31 +02:00
index.rst docs: netlink: index.rst: add a netlink index file 2025-08-12 07:47:30 +02:00
lockd.yaml netlink: specs: clean up spaces in brackets 2025-06-11 14:01:19 -07:00
mptcp_pm.yaml mptcp: fix kdoc warnings 2026-02-06 20:35:06 -08:00
net_shaper.yaml net: shaper: reject handle IDs exceeding internal bit-width 2026-05-12 16:15:00 +02:00
netdev.yaml net: Add queue-create operation 2026-04-09 18:21:45 -07:00
nfsd.yaml NFSD: Add a key for signing filehandles 2026-03-29 21:25:09 -04:00
nftables.yaml doc/netlink: nftables: Fill out operation attributes 2026-03-05 18:49:08 -08:00
nl80211.yaml netlink: specs: explicitly declare block scalar strings 2025-09-15 18:27:19 -07:00
nlctrl.yaml netlink: specs: clean up spaces in brackets 2025-06-11 14:01:19 -07:00
ovpn.yaml ovpn: add support for asymmetric peer IDs 2026-03-17 11:09:05 +01:00
ovs_datapath.yaml netlink: specs: explicitly declare block scalar strings 2025-09-15 18:27:19 -07:00
ovs_flow.yaml netlink: specs: explicitly declare block scalar strings 2025-09-15 18:27:19 -07:00
ovs_vport.yaml netlink: specs: explicitly declare block scalar strings 2025-09-15 18:27:19 -07:00
psp.yaml net: psp: require admin permission for dev-set and key-rotate 2026-04-28 17:44:20 -07:00
rt-addr.yaml netlink: specs: add big-endian byte-order for u32 IPv4 addresses 2025-11-26 17:14:17 -08:00
rt-link.yaml net: bridge: add stp_mode attribute for STP mode selection 2026-04-10 15:52:24 -07:00
rt-neigh.yaml netlink: specs: support ipv4-or-v6 for dual-stack fields 2025-11-18 18:42:10 -08:00
rt-route.yaml netlink: specs: support ipv4-or-v6 for dual-stack fields 2025-11-18 18:42:10 -08:00
rt-rule.yaml netlink: specs: support ipv4-or-v6 for dual-stack fields 2025-11-18 18:42:10 -08:00
tc.yaml net/sched: sch_cake: share shaper state across sub-instances of cake_mq 2026-01-13 11:54:29 +01:00
tcp_metrics.yaml netlink: specs: clean up spaces in brackets 2025-06-11 14:01:19 -07:00
team.yaml netlink: specs: team: avoid mangling multilines doc 2025-09-15 18:27:19 -07:00
wireguard.yaml wireguard: netlink: add YNL specification 2025-12-02 04:12:19 +01:00