Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795025508; b=oAwG45FSBVPxfMgx956kuIeu7ZiURf7q/cHNjdjYtNK1cw+kiTdiWnQVBj9dajXVp4wo p+bvlrWP2V9CQL9RLPUeqjpZiipaQtmRAvmLm/GqcV6iFKNIt9oH4yMFlvIaNLEhLyerL J2vuGgRyMHFIWxNPnVpbfTPM2cHu510xzS71y7eZPSYBh/lIk6vMM33lnBivVIoHFQ2ZR P3JO2XvjdY1R/7VfaZ1TppJDNbIo8zrB6mU5/+87nRi2kShjWvH6xLt1grm5+PtHgYVKq 1EhxIGmWFyMXXeXJOpO/j6egy6rReEKAhAtUy6VU2xhs27rDyuatZVEvAkfo6SwpGjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795025508; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=6H35l/hq5D+tyqS34nuSXew/O229akLDWvZAPh6HeHc=; b=yf//7VjyjdibZO8jomdy6L73+Dyi2dK516mRKfQz2W+n+nYJXjALlrxpFD+9UMvVPYyb Pb9pcllCEHNI/jtr8Kc6fboQLySSj5UMOBRvpIa+Qyfzvd1AManXOqHsooazCWKRhmyAK wM4WrbdYhhU2NqwDGQWGZ5mNVWHUxvj2Tu9v2vF9UKuuop6+zXT3Xe3Rx4g7HfcPISbdU vY2Xir60c7uUvAtrGfea9lpG7bLC58aj0elz1u6rlCXSvh+a+xwbf0QfcFAr3iNRrtV2x d0VN1gnnDanc1zMAJQrPckwc5qbX7HZ764dmNgX/aorZgMh0jK7rgbqgRs1Q5Nl1IHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DLEHeGGe; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0E46606A330; Wed, 18 Nov 2026 18:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DLEHeGGe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 340B11F000C5; Wed, 18 Nov 2026 18:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795025508; bh=6H35l/hq5D+tyqS34nuSXew/O229akLDWvZAPh6HeHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DLEHeGGegrXEwR5HrJYiJCfJqRwNDX7zJdqRoj/SeV4OrDDfi0wJZ1n56spf8v7G9 FBK27Fd7BW5MtPuIavIGSrGCpswxU78bKwhB/RUAGLWylJHTMQA8RV1kfHkzUiCzkB O9HxKBB8JQgj2wPFpr/e2V+gm/eT8b0YhdJS+/2A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chuck Lever , Anna Schumaker , Sasha Levin Subject: [PATCH 6.18 1102/2151] SUNRPC: reject a client-side TLS alert record that is not two octets Date: Wed, 18 Nov 2026 15:47:17 +0100 Message-ID: <20261118150202.399743380@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever [ Upstream commit 1e87497aac8d2d4aee9b288ba43f58d1690b9a89 ] tls_alert_recv() reads two octets from the kvec it is handed and does not check the length (net/handshake/alert.c). xs_sock_process_cmsg() calls it for any alert record, and the alert[] buffer that xs_sock_recv_cmsg() supplies carries no initializer. A one-octet alert body leaves the description read from uninitialized stack and reported through trace_tls_alert_recv(). The peer controls that length. Neither tls_rx_msg_size() nor tls_rx_one_record() enforces the two-octet Alert payload. A TLS 1.3 record carrying only the inner content-type octet decrypts to a zero-length payload. RFC 8446 Section 5.1 requires a record with an Alert type to carry exactly one message, so any other length is malformed. RFC 9289 Section 5 bars RPC-with-TLS from negotiating a version below TLS 1.3, so no other alert framing applies. Require exactly two octets before parsing and return -EACCES otherwise. xs_stream_data_receive() already treats -EACCES as a fatal alert and reports it to the pending tasks. Gate the path on a control message rather than a positive count so that a zero-length record reaches the check. Fixes: cc5d59081fa2 ("sunrpc: fix client side handling of tls alerts") Signed-off-by: Chuck Lever Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- net/sunrpc/xprtsock.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 2946f6b562fbc..04e0052c565b8 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -407,9 +407,25 @@ xs_sock_recv_cmsg(struct socket *sock, unsigned int *msg_flags, int flags) iov_iter_kvec(&msg.msg_iter, ITER_DEST, &alert_kvec, 1, alert_kvec.iov_len); ret = sock_recvmsg(sock, &msg, flags); - if (ret > 0) { - if (tls_get_record_type(sock->sk, &u.cmsg) == TLS_RECORD_TYPE_ALERT) + /* put_cmsg() shrinks msg_controllen, so a short one means + * kTLS filled in u.cmsg. + */ + if (ret >= 0 && msg.msg_controllen < sizeof(u)) { + if (tls_get_record_type(sock->sk, &u.cmsg) == + TLS_RECORD_TYPE_ALERT) { + /* RFC 8446 Section 5.1 requires a record with an + * Alert type to carry exactly one message. An alert + * is two octets. tls_alert_recv() reads both without + * checking the length. alert_kvec caps the count at + * two, so a longer record fills it as well. kTLS + * sets MSG_EOR only once the record has been + * drained. + */ + if (ret != sizeof(alert) || + !(msg.msg_flags & MSG_EOR)) + return -EACCES; iov_iter_revert(&msg.msg_iter, ret); + } ret = xs_sock_process_cmsg(sock, &msg, msg_flags, &u.cmsg, -EAGAIN); } -- 2.53.0