diff mbox series

[net] net/tls: avoid potential deadlock in tls_set_device_offload_rx()

Message ID 20190419235138.31310-1-jakub.kicinski@netronome.com
State Accepted
Delegated to: David Miller
Headers show
Series [net] net/tls: avoid potential deadlock in tls_set_device_offload_rx() | expand

Commit Message

Jakub Kicinski April 19, 2019, 11:51 p.m. UTC
If device supports offload, but offload fails tls_set_device_offload_rx()
will call tls_sw_free_resources_rx() which (unhelpfully) releases
and reacquires the socket lock.

For a small fix release and reacquire the device_offload_lock.

Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 net/tls/tls_device.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Miller April 21, 2019, 3:36 a.m. UTC | #1
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri, 19 Apr 2019 16:51:38 -0700

> If device supports offload, but offload fails tls_set_device_offload_rx()
> will call tls_sw_free_resources_rx() which (unhelpfully) releases
> and reacquires the socket lock.
> 
> For a small fix release and reacquire the device_offload_lock.
> 
> Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>

Applied and queued up for -stable, thanks.
diff mbox series

Patch

diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 9f3bdbc1e593..1b5f55cac613 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -904,7 +904,9 @@  int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
 	goto release_netdev;
 
 free_sw_resources:
+	up_read(&device_offload_lock);
 	tls_sw_free_resources_rx(sk);
+	down_read(&device_offload_lock);
 release_ctx:
 	ctx->priv_ctx_rx = NULL;
 release_netdev: