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=1796385225; b=aGbKIfbZnGj/IGuoC2baCj1h5az+NtIbD2M11d2YxJJnQFa99G2aMtnksHm0BqmfVXJ2 HKDhwJEoXVvzpEr+JKJ5LWaLdDE6NOf9MRhRNd9RiMQ7NuIOVikKvx+S9XbE9HcK3EIu1 I0yIgIWYW7NTvsXm00N43rb+kNo1l96Czkr60Gtu9CtY8BfEt0+9NCOS5YMFGgXYGoEQy pRDcVX1dUobRNeO2D9SEGNC4Yt1FNpoDlXAWtd3jYLTCAKb0tNJOS4NOFe/07Z3fYAh5i +VspxUDT7bh7wtye9xOA6U/TzoY9WG0RvV7OabnJRuR3S+ntyMZE4D2WsmFQlf73eRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385225; 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=o6EAwlhBkA21Sa8FAGCe/nFhTNWy5iT5fWIQbYcT2AY=; b=HzJXlYTD3++bEhAkoBjo/T87el+2wpy1KB/KuLrZcAruL9PLjLJnartTb9o9Qmpbb2q4 icFKp40nruXtFxzZhV9i3MCU/QDe3FoHFFFrO8/O0o+LgTkxGSx+IxYfpcVZzxKcELE1r +S8ltKTt3OEN34KsCL12tUBDCi1VE6BLrVLAEwLUJBBYvs3dGB1kGTBaqPjuVrUY4aTrH S5cZ+eVNArEjt+N4W+bvLEyKbs/YpKEIJQHVBSfRpIQK52EOBbWGmMQPmgX8b/4mjObwi q4eV6RD723SciZkJMbdqgeCjp7Ytl8PiFcrkZ7ELfGar2Vfr8Y/qBgLFk8T6iNmNTCQ== 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=SskpE7qZ; 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 53FA4606A335; Fri, 4 Dec 2026 11:53:45 +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=SskpE7qZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5A5B1F000C2; Fri, 4 Dec 2026 11:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385225; bh=o6EAwlhBkA21Sa8FAGCe/nFhTNWy5iT5fWIQbYcT2AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SskpE7qZPL5QnIhsHv8tUF0pbQmYkStrvlEerA4yJLSwKrg0xSGWU4ThAwKh9Rw/D X5fdREJVn0wdZggyoMhq6UYw7pUWb0xNs3UD6KSz2OLipW49iYVjRTMUdrJJEs+kgO TMV8xfQAykW6sRfMNXXi6zX1pqqaWumvE2Hw0Eis= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chuck Lever , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0471/1167] tls: Honor O_NONBLOCK in tls_sw_splice_read() Date: Fri, 4 Dec 2026 18:58:18 +0900 Message-ID: <20261204100714.290688046@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever [ Upstream commit 78ded647d43e335891f981f68c5992a2e763cfcc ] tls_sw_splice_read() takes its blocking behavior from SPLICE_F_NONBLOCK alone. When splicing from a socket to a pipe, do_splice() sets that flag from the pipe's O_NONBLOCK, not the socket's. On a nonblocking socket, a splice(2) call without SPLICE_F_NONBLOCK therefore sleeps in tls_rx_rec_wait() until a record arrives. tcp_splice_read() instead reads sock->file->f_flags and returns -EAGAIN. Polling first does not avoid the sleep once tls_sw_splice_read() consumes zero-length records, as it does after a later patch in this series. tls_sw_sock_is_readable() reports the socket readable while any record sits on rx_list, including a zero-length record that delivers no bytes to the pipe. For TLS 1.3 the strparser announces a record before decryption, when its plaintext length is still unknown, so the readiness test cannot screen such a record out. A splice that consumes the record and waits for the next stalls every connection an event loop multiplexes. An LLM audit of the TLS read paths found this defect. Treat the socket's O_NONBLOCK as nonblocking too. A caller that sets O_NONBLOCK on the socket and splices without SPLICE_F_NONBLOCK now gets -EAGAIN where the splice blocked before. sendfile(2) from a TLS socket changes the same way, because do_sendfile() leaves the input file's O_NONBLOCK out of the splice flags. Both now behave as they do on a plain TCP socket. Fixes: c46234ebb4d1 ("tls: RX path for ktls") Signed-off-by: Chuck Lever Link: https://patch.msgid.link/20261027015215.605919-2-kuba@kernel.org Signed-off-by: Jakub Kicinski [ sashal: Added a local bool nonblock as upstream does, but kept this tree's extra NULL psock argument in the tls_rx_rec_wait() call. ] Signed-off-by: Sasha Levin --- net/tls/tls_sw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index e4990ccbe8ba0..3014a5bbeabab 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -2299,10 +2299,14 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, struct tls_msg *tlm; struct sk_buff *skb; ssize_t copied = 0; + bool nonblock; int chunk; int err; - err = tls_rx_reader_lock(sk, ctx, flags & SPLICE_F_NONBLOCK); + nonblock = flags & SPLICE_F_NONBLOCK || + sock->file->f_flags & O_NONBLOCK; + + err = tls_rx_reader_lock(sk, ctx, nonblock); if (err < 0) return err; @@ -2316,8 +2320,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, } else { struct tls_decrypt_arg darg; - err = tls_rx_rec_wait(sk, NULL, flags & SPLICE_F_NONBLOCK, - true, false); + err = tls_rx_rec_wait(sk, NULL, nonblock, true, false); if (err <= 0) goto splice_read_end; -- 2.53.0