* [PATCH net] tls: fix lockless read of strp->msg_ready in ->poll
@ 2024-04-24 10:25 Sabrina Dubroca
2024-04-25 15:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Sabrina Dubroca @ 2024-04-24 10:25 UTC (permalink / raw)
To: netdev
Cc: Sabrina Dubroca, Jakub Kicinski, Paolo Abeni, Boris Pismenny,
John Fastabend, David S. Miller, Eric Dumazet
tls_sk_poll is called without locking the socket, and needs to read
strp->msg_ready (via tls_strp_msg_ready). Convert msg_ready to a bool
and use READ_ONCE/WRITE_ONCE where needed. The remaining reads are
only performed when the socket is locked.
Fixes: 121dca784fc0 ("tls: suppress wakeups unless we have a full record")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
include/net/tls.h | 3 ++-
net/tls/tls.h | 2 +-
net/tls/tls_strp.c | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/net/tls.h b/include/net/tls.h
index 340ad43971e4..33f657d3c051 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -111,7 +111,8 @@ struct tls_strparser {
u32 stopped : 1;
u32 copy_mode : 1;
u32 mixed_decrypted : 1;
- u32 msg_ready : 1;
+
+ bool msg_ready;
struct strp_msg stm;
diff --git a/net/tls/tls.h b/net/tls/tls.h
index 762f424ff2d5..e5e47452308a 100644
--- a/net/tls/tls.h
+++ b/net/tls/tls.h
@@ -215,7 +215,7 @@ static inline struct sk_buff *tls_strp_msg(struct tls_sw_context_rx *ctx)
static inline bool tls_strp_msg_ready(struct tls_sw_context_rx *ctx)
{
- return ctx->strp.msg_ready;
+ return READ_ONCE(ctx->strp.msg_ready);
}
static inline bool tls_strp_msg_mixed_decrypted(struct tls_sw_context_rx *ctx)
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
index ca1e0e198ceb..5df08d848b5c 100644
--- a/net/tls/tls_strp.c
+++ b/net/tls/tls_strp.c
@@ -360,7 +360,7 @@ static int tls_strp_copyin(read_descriptor_t *desc, struct sk_buff *in_skb,
if (strp->stm.full_len && strp->stm.full_len == skb->len) {
desc->count = 0;
- strp->msg_ready = 1;
+ WRITE_ONCE(strp->msg_ready, 1);
tls_rx_msg_ready(strp);
}
@@ -528,7 +528,7 @@ static int tls_strp_read_sock(struct tls_strparser *strp)
if (!tls_strp_check_queue_ok(strp))
return tls_strp_read_copy(strp, false);
- strp->msg_ready = 1;
+ WRITE_ONCE(strp->msg_ready, 1);
tls_rx_msg_ready(strp);
return 0;
@@ -580,7 +580,7 @@ void tls_strp_msg_done(struct tls_strparser *strp)
else
tls_strp_flush_anchor_copy(strp);
- strp->msg_ready = 0;
+ WRITE_ONCE(strp->msg_ready, 0);
memset(&strp->stm, 0, sizeof(strp->stm));
tls_strp_check_rcv(strp);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] tls: fix lockless read of strp->msg_ready in ->poll
2024-04-24 10:25 [PATCH net] tls: fix lockless read of strp->msg_ready in ->poll Sabrina Dubroca
@ 2024-04-25 15:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-25 15:40 UTC (permalink / raw)
To: Sabrina Dubroca
Cc: netdev, kuba, pabeni, borisp, john.fastabend, davem, edumazet
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 24 Apr 2024 12:25:47 +0200 you wrote:
> tls_sk_poll is called without locking the socket, and needs to read
> strp->msg_ready (via tls_strp_msg_ready). Convert msg_ready to a bool
> and use READ_ONCE/WRITE_ONCE where needed. The remaining reads are
> only performed when the socket is locked.
>
> Fixes: 121dca784fc0 ("tls: suppress wakeups unless we have a full record")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
>
> [...]
Here is the summary with links:
- [net] tls: fix lockless read of strp->msg_ready in ->poll
https://git.kernel.org/netdev/net/c/0844370f8945
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-25 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 10:25 [PATCH net] tls: fix lockless read of strp->msg_ready in ->poll Sabrina Dubroca
2024-04-25 15:40 ` patchwork-bot+netdevbpf
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.