From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796380559; b=B9UHURGsTtF4gvqMA+6RDVROpEE85yCkxXv+KBpZ3N0qARsGb9NCNFQGMxLUEkjLyZjf ePecSh61/dY8VIg8KOQB5FM5iEnJMonPBnHn0YpX+3sUFyMN1cN+fjkBYylZ2tGhxPCmV V/f9zcLleTkK4mzI2gDsjAjCgYpcdmdiGzDXPhfmkF+eq2CN5i2Gy/l3Ol9hgMx+y92TR GEQR5aoUdc6rGVjHtJc677mxkT635fKJZpm/m+XNIJTDYkXEG1ox/cM+O3PPkzDBcVQcw 9M4Q0NQZpoTHpyeZDxekFMnijE/IoXGN0QgEFvIFGGCjSHuVoO9Dl/SOpGVEcgtBHHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380559; 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=cs7R0lg1HM4yHwSJNzm0dn1M3C47o2MmFgMX+/mpknI=; b=zJeK79KcSuyngTs9SmD7CkL2cqAGNaoLWZoPccfe014Hd/YeabnWiZVvH68vKgAZDXxt kx8IQH+cNSs3CBzrg8uP0JtuZf/Ubnhm5/FOHQOkpmA9jOA6ZuOmklSWndCmM3w9JZaVT /G/YVh/3rpagYbwGmy5txQh8AxKzNPTj9ekzdGLjGVmntU/e1/72NciqiRv0hA2VEywF8 RZH/sVO5eNlA+WPWi4cKBJuaCKAWeNYr+l7sbsVHo7iXwTivbeNjur2k+uLClczcGmnKM 3Il2gkf+xHdaBD4VuXLHxTQvKM9eeb+TxkOMiGeuyHAFaqM/Vx5td/lnOMqp2SVC1cw== 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=0WO4NgRN; 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 24DB1606A680; Fri, 4 Dec 2026 10:35:58 +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=0WO4NgRN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B2FE1F000CE; Fri, 4 Dec 2026 10:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380558; bh=cs7R0lg1HM4yHwSJNzm0dn1M3C47o2MmFgMX+/mpknI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0WO4NgRNTeSYaT9mWG2+A7LCiIP9QVXEvJBvElhu/m+ipdK/rmFkupDsm1MQQovOw ff6bQBmTeCaM+KYt3up/k4yHmYxC7trUgm0kBqwrMyr3RQxDcqSP5/w3bYgY0lMpNg 0Jc/xznOk7z9tAk2SWD16ikChBbvIOTZlOGfI2uM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Felipe Pereira Stival , Simon Horman , Sabrina Dubroca , Paolo Abeni , Sasha Levin Subject: [PATCH 7.3 309/742] tls: dont hide a queued KeyUpdate from poll() Date: Fri, 4 Dec 2026 19:02:53 +0900 Message-ID: <20261204100643.237579929@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Felipe Pereira Stival [ Upstream commit 285ca329ad4bfc32d0f383340c40a40c8157ac7c ] When application data and a KeyUpdate are both queued, the recv() for the data can also decrypt the KeyUpdate. That makes a rekey pending, and the KeyUpdate is left on rx_list because its record type differs. tls_sk_poll() reports no read events while a rekey is pending, so the socket doesn't poll readable although a recvmsg() would return the KeyUpdate. A reader that waits for a read event before each recv() never reads it, never provides the new key and receives nothing more. Report read events for records on rx_list while a rekey is pending, since they are already decrypted. Keep ignoring the records still in the strparser, so once the KeyUpdate has been read there are no read events until the new key is provided, as before. Update the documentation to say so. Found with a level-triggered epoll reader that does one recv() per read event. Without this patch it gets the data and then no read event for the KeyUpdate; with it, the KeyUpdate is reported and the rekey completes. Fixes: 47069594e67e ("tls: implement rekey for TLS1.3") Signed-off-by: Felipe Pereira Stival Reviewed-by: Simon Horman Reviewed-by: Sabrina Dubroca Link: https://patch.msgid.link/20261118-v0idpwn-tls-poll-parked-keyupdate-v1-1-8e25101e7be6@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- Documentation/networking/tls.rst | 7 ++++--- net/tls/tls_main.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/tls.rst b/Documentation/networking/tls.rst index 980c442d7161a..e07c1a001b217 100644 --- a/Documentation/networking/tls.rst +++ b/Documentation/networking/tls.rst @@ -215,9 +215,10 @@ To prevent attempting to decrypt incoming records using the wrong key, decryption will be paused when a KeyUpdate message is received by the kernel, until the new key has been provided using the TLS_RX socket option. Any read occurring after the KeyUpdate has been read and -before the new key is provided will fail with EKEYEXPIRED. poll() will -not report any read events from the socket until the new key is -provided. There is no pausing on the transmit side. +before the new key is provided will fail with EKEYEXPIRED. Once the +KeyUpdate has been read, poll() will not report any read events from +the socket until the new key is provided. There is no pausing on the +transmit side. Userspace should make sure that the crypto_info provided has been set properly. In particular, the kernel will not check for key/nonce diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index f13faafe58d20..270b3aa708eb0 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -416,9 +416,9 @@ static __poll_t tls_sk_poll(struct file *file, struct socket *sock, tls_ctx = tls_get_ctx(sk); ctx = tls_sw_ctx_rx(tls_ctx); - if ((skb_queue_empty_lockless(&ctx->rx_list) && - !tls_strp_msg_ready(ctx)) || - READ_ONCE(ctx->key_update_pending)) + if (skb_queue_empty_lockless(&ctx->rx_list) && + (!tls_strp_msg_ready(ctx) || + READ_ONCE(ctx->key_update_pending))) mask &= ~(EPOLLIN | EPOLLRDNORM); return mask; -- 2.53.0