[PATCH v2 0/8] SUNRPC: Fix TLS control record handling
From: Chuck Lever <cel@kernel.org>
Date: 2026-08-06 20:20:29
Also in:
linux-nfs
The read_sock_rectype proto_ops method is not going forward. Designing its replacement meant another pass over the receive path it was meant to replace, and that pass turned up the defects fixed here. None arrived as a bug report. The code path that handles TLS Alerts on behalf of in-kernel kTLS consumers has been reworked twice already. For the record: 5e052dda121e added control message recognition, and 39067dda1d86 moved the parsing into the net/handshake helpers. bee47cb026e7 and cc5d59081fa2 then reworked both sides after Scott Mayhew reported that kTLS was writing alert bodies into the RPC receive buffer. Mounts against a FreeBSD server over mutual TLS broke, and 9559d2fffd4f restored the other cmsg types. The same rework moved the receive into a local buffer, but the length accounting did not follow. A control record's octets are credited to the RPC stream, and a consumed control record leaves the server transport unmarked. The peer still controls the alert body's length, and nothing checks it before tls_alert_recv() reads two octets. A peer that aborts with an error alert while leaving that octet set to warning currently leaves a dead TLS session attached to a live transport. These accounting defects do not have a trigger today. Both need a peer that sends a post-handshake control record (e.g., KeyUpdate). However, no existing RPC-with-TLS implementation does this today. Therefore these patches are posted as individual fixes that can be backported if LTS kernels should need to interoperate when KeyUpdate subsequently arrives in clients and servers. Eagle-eyed reviewers might notice that the two call sites this series touches are the last consumers of <net/tls_prot.h> in net/sunrpc/. Both sites now state the same record-type test, the same two-octet rule, and the same closure classification. A helper in net/handshake/alert.c could hold all three and return a verdict, which would let net/sunrpc/ drop the header and keep only the transport policy. That is deferred to a next step rather than included as part of this series to keep LTS backports practical. I'd appreciate an Acked-by from the client maintainers for the three patches that touch xprtsock.c. --- Changes in v2: - Series reorder: length check goes before the severity change it guards - Reword the XPT_DATA comment to drop an overstated guarantee - Link to v1: https://patch.msgid.link/20260805-svcsock-cmsg-fixes-v1-0-43514a32da9b@kernel.org --- Chuck Lever (8): SUNRPC: do not credit control-record octets to the RPC stream SUNRPC: reject a TLS alert record that is not two octets SUNRPC: treat every TLS error alert as fatal SUNRPC: resume receiving after a TLS control record SUNRPC: fold svc_tcp_sock_process_cmsg() into its only caller SUNRPC: reject a client-side TLS alert record that is not two octets SUNRPC: treat every client-side TLS error alert as fatal SUNRPC: fold xs_sock_process_cmsg() into its only caller net/sunrpc/svcsock.c | 108 +++++++++++++++++++++++++++++++++++++------------- net/sunrpc/xprtsock.c | 69 ++++++++++++++++---------------- 2 files changed, 115 insertions(+), 62 deletions(-) --- base-commit: 0b6d2c7e3abca8d17fddeecb6e4c32a8438ec2fb change-id: 20260805-svcsock-cmsg-fixes-9165f6cbb8de Best regards, -- Chuck Lever [off-list ref]