From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A886314B8F; Mon, 27 Oct 2025 19:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591938; cv=none; b=V1AamR5Orn5Ng3sobMgz4ww8KEArnbr8Vmto+J6+wsepupSrZqFzN8aDkc7XvfaEWpwH84Ct8EHaVIWdAwmLAOHGRQOUWysEAHsnwM7cH4muB/mIrjh6hYDLxSzSP3MwmAYEZccEctuna6/efCsEhf0fYZkbI41E2nVRtTRJWOk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591938; c=relaxed/simple; bh=L4Bq+KR91PYrzvsedznpZ+ORq6CYUWsm2+Ha3Bx0hs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4xGJqOWcZ9WJEOqPVIHXugxaVnTh/buGHjMv2JE/x/1GswSDwA+Qf3qUz6kj7niQAMme9phrzfLhN/27JlfbFjkhxpVEFTNYLllCQ80au2KV00DfzCW+N8KOiqffov15Sxyq3/kbIJvePIxFwY4+9oG5KyekcYdshT4tEgiHcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cDLZp8kr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="cDLZp8kr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8BE9C4CEF1; Mon, 27 Oct 2025 19:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761591938; bh=L4Bq+KR91PYrzvsedznpZ+ORq6CYUWsm2+Ha3Bx0hs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cDLZp8krvnV4SAAC47wFu4qXjOubCvGxm1CHoFXXzRXfT0/7T41f5GLsLfI+GfwPL ZrPltJxar3BmXPeyW8p0tWJMyoobJcMJJ/nXPLDoEx4VBV4C0X8vzX5xcPvo4SooPt gZ62vetaS6MLw5M+WVDQroOrnh0veYv0gwWQYRjc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jann Horn , Sabrina Dubroca , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 028/123] tls: dont rely on tx_work during send() Date: Mon, 27 Oct 2025 19:35:08 +0100 Message-ID: <20251027183447.152807558@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183446.381986645@linuxfoundation.org> References: <20251027183446.381986645@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sabrina Dubroca [ Upstream commit 7f846c65ca11e63d2409868ff039081f80e42ae4 ] With async crypto, we rely on tx_work to actually transmit records once encryption completes. But while send() is running, both the tx_lock and socket lock are held, so tx_work_handler cannot process the queue of encrypted records, and simply reschedules itself. During a large send(), this could last a long time, and use a lot of memory. Transmit any pending encrypted records before restarting the main loop of tls_sw_sendmsg_locked. Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance") Reported-by: Jann Horn Signed-off-by: Sabrina Dubroca Link: https://patch.msgid.link/8396631478f70454b44afb98352237d33f48d34d.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tls/tls_sw.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index e08edfc639fd5..110859f7e5e3e 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1089,6 +1089,13 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) else if (ret != -EAGAIN) goto send_end; } + + /* Transmit if any encryptions have completed */ + if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) { + cancel_delayed_work(&ctx->tx_work.work); + tls_tx_records(sk, msg->msg_flags); + } + continue; rollback_iter: copied -= try_to_copy; @@ -1143,6 +1150,12 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) goto send_end; } } + + /* Transmit if any encryptions have completed */ + if (test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) { + cancel_delayed_work(&ctx->tx_work.work); + tls_tx_records(sk, msg->msg_flags); + } } continue; -- 2.51.0