]> git.hungrycats.org Git - linux/commitdiff
SUNRPC: Treat every TLS error alert as fatal
authorChuck Lever <cel@kernel.org>
Sat, 8 Aug 2026 15:40:11 +0000 (11:40 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:08 +0000 (12:06 -0500)
commit 2c0dfe9d6d81e4bc9201b11dab3876cbfd01884e upstream.

svc_tcp_sock_process_cmsg() decides whether an alert ends the session
by reading the alert's level octet. RFC 8446 Section 6 retired that
field. The severity is implicit in the description, and a receiver
treats every alert listed in Section 6.2 as an error alert
"regardless of the AlertLevel in the message". A peer that aborts
with unexpected_message but leaves the legacy octet set to warning
makes the server return -EAGAIN. svc_tcp_recvfrom() then leaves a
dead TLS session attached to an open transport. NFSD keeps polling
it.

Decide from the alert description instead. close_notify and
user_canceled are the closure alerts (RFC 8446 Section 6.1). Every
other description ends the session, including one this kernel does
not recognize.

Fixes: 39067dda1d86 ("SUNRPC: Use new helpers to handle TLS Alerts")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260808-svcsock-cmsg-fixes-v3-3-62d9a631c880@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/svcsock.c

index 53d02920d11299c14a2b5ccce0971dc1bc3a6326..5cf9b43f27831aa50128ddd203994ef3f283e3bf 100644 (file)
@@ -290,8 +290,17 @@ svc_tcp_sock_process_cmsg(struct socket *sock, struct msghdr *msg,
                break;
        case TLS_RECORD_TYPE_ALERT:
                tls_alert_recv(sock->sk, msg, &level, &description);
-               ret = (level == TLS_ALERT_LEVEL_FATAL) ?
-                       -ENOTCONN : -EAGAIN;
+               /* RFC 8446 Section 6: every alert but a closure alert is
+                * an error alert.
+                */
+               switch (description) {
+               case TLS_ALERT_DESC_CLOSE_NOTIFY:
+               case TLS_ALERT_DESC_USER_CANCELED:
+                       ret = -EAGAIN;
+                       break;
+               default:
+                       ret = -ENOTCONN;
+               }
                break;
        default:
                /* discard this record type */