From: Shaoying Xu <shaoyi@amazon.com>
To: <gregkh@linuxfoundation.org>, <stable@vger.kernel.org>
Cc: <shaoyi@amazon.com>, <sd@queasysnail.net>, <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>
Subject: [PATCH 5.15 1/5] tls: rx: simplify async wait
Date: Tue, 7 May 2024 22:18:02 +0000 [thread overview]
Message-ID: <20240507221806.30480-2-shaoyi@amazon.com> (raw)
In-Reply-To: <20240507221806.30480-1-shaoyi@amazon.com>
From: Jakub Kicinski <kuba@kernel.org>
commit 37943f047bfb88ba4dfc7a522563f57c86d088a0 upstream.
Since we are protected from async completions by decrypt_compl_lock
we can drop the async_notify and reinit the completion before we
start waiting.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: aec7961916f3 ("tls: fix race between async notify and socket close")
Cc: <stable@vger.kernel.org> # 5.15
Signed-off-by: Shaoying Xu <shaoyi@amazon.com>
---
include/net/tls.h | 1 -
net/tls/tls_sw.c | 14 ++------------
2 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/include/net/tls.h b/include/net/tls.h
index ea0aeae26cf7..dcd6aa08c067 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -150,7 +150,6 @@ struct tls_sw_context_rx {
atomic_t decrypt_pending;
/* protect crypto_wait with decrypt_pending*/
spinlock_t decrypt_compl_lock;
- bool async_notify;
};
struct tls_record_info {
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index fc55b65695e5..9c443646417e 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -174,7 +174,6 @@ static void tls_decrypt_done(struct crypto_async_request *req, int err)
struct scatterlist *sg;
struct sk_buff *skb;
unsigned int pages;
- int pending;
skb = (struct sk_buff *)req->data;
tls_ctx = tls_get_ctx(skb->sk);
@@ -222,9 +221,7 @@ static void tls_decrypt_done(struct crypto_async_request *req, int err)
kfree(aead_req);
spin_lock_bh(&ctx->decrypt_compl_lock);
- pending = atomic_dec_return(&ctx->decrypt_pending);
-
- if (!pending && ctx->async_notify)
+ if (!atomic_dec_return(&ctx->decrypt_pending))
complete(&ctx->async_wait.completion);
spin_unlock_bh(&ctx->decrypt_compl_lock);
}
@@ -1917,7 +1914,7 @@ int tls_sw_recvmsg(struct sock *sk,
/* Wait for all previously submitted records to be decrypted */
spin_lock_bh(&ctx->decrypt_compl_lock);
- ctx->async_notify = true;
+ reinit_completion(&ctx->async_wait.completion);
pending = atomic_read(&ctx->decrypt_pending);
spin_unlock_bh(&ctx->decrypt_compl_lock);
if (pending) {
@@ -1929,15 +1926,8 @@ int tls_sw_recvmsg(struct sock *sk,
decrypted = 0;
goto end;
}
- } else {
- reinit_completion(&ctx->async_wait.completion);
}
- /* There can be no concurrent accesses, since we have no
- * pending decrypt operations
- */
- WRITE_ONCE(ctx->async_notify, false);
-
/* Drain records from the rx_list & copy if required */
if (is_peek || is_kvec)
err = process_rx_list(ctx, msg, &control, copied,
--
2.40.1
next prev parent reply other threads:[~2024-05-07 22:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 22:18 [PATCH 5.15 0/5] Backport CVE-2024-26583 and CVE-2024-26584 fixes Shaoying Xu
2024-05-07 22:18 ` Shaoying Xu [this message]
2024-05-07 22:18 ` [PATCH 5.15 2/5] tls: extract context alloc/initialization out of tls_set_sw_offload Shaoying Xu
2024-05-07 22:18 ` [PATCH 5.15 3/5] net: tls: factor out tls_*crypt_async_wait() Shaoying Xu
2024-05-07 22:18 ` [PATCH 5.15 4/5] tls: fix race between async notify and socket close Shaoying Xu
2024-05-07 22:18 ` [PATCH 5.15 5/5] net: tls: handle backlogging of crypto requests Shaoying Xu
2024-05-23 11:43 ` [PATCH 5.15 0/5] Backport CVE-2024-26583 and CVE-2024-26584 fixes Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240507221806.30480-2-shaoyi@amazon.com \
--to=shaoyi@amazon.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=kuba@kernel.org \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.