]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/tls: avoid potential deadlock in tls_set_device_offload_rx()
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 19 Apr 2019 23:51:38 +0000 (16:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 21 Apr 2019 03:35:28 +0000 (20:35 -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: 81b6ef1732a9 ("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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tls/tls_device.c

index 9f3bdbc1e59348cf049c0cca9959ee5f413e41cb..1b5f55cac613d1416a64bbc900418c8cc1a9267a 100644 (file)
@@ -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: