net/tls: make sure offload also gets the keys wiped
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 28 Jun 2019 23:11:39 +0000 (16:11 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jul 2019 02:22:36 +0000 (19:22 -0700)
Commit 86029d10af18 ("tls: zero the crypto information from tls_context
before freeing") added memzero_explicit() calls to clear the key material
before freeing struct tls_context, but it missed tls_device.c has its
own way of freeing this structure. Replace the missing free.

Fixes: 86029d10af18 ("tls: zero the crypto information from tls_context before freeing")
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>
include/net/tls.h
net/tls/tls_device.c
net/tls/tls_main.c

index 53d96bca220d0744b9ce46e68dcafef56d9ac864..889df0312cd10d11b4c8353bbdfb05e294b57921 100644 (file)
@@ -313,6 +313,7 @@ struct tls_offload_context_rx {
        (ALIGN(sizeof(struct tls_offload_context_rx), sizeof(void *)) + \
         TLS_DRIVER_STATE_SIZE)
 
+void tls_ctx_free(struct tls_context *ctx);
 int wait_on_pending_writer(struct sock *sk, long *timeo);
 int tls_sk_query(struct sock *sk, int optname, char __user *optval,
                int __user *optlen);
index 397990407ed6c3ec4ab8d6f17548a6ce3dd42631..eb8f24f420f0fe48041cd799b0f84cf51d7a80c4 100644 (file)
@@ -61,7 +61,7 @@ static void tls_device_free_ctx(struct tls_context *ctx)
        if (ctx->rx_conf == TLS_HW)
                kfree(tls_offload_ctx_rx(ctx));
 
-       kfree(ctx);
+       tls_ctx_free(ctx);
 }
 
 static void tls_device_gc_task(struct work_struct *work)
index e2b69e805d4640805bd46edca86c6a7930bfe91d..4674e57e66b0533fc5faf5ae930c0aad85eb8b77 100644 (file)
@@ -251,7 +251,7 @@ static void tls_write_space(struct sock *sk)
        ctx->sk_write_space(sk);
 }
 
-static void tls_ctx_free(struct tls_context *ctx)
+void tls_ctx_free(struct tls_context *ctx)
 {
        if (!ctx)
                return;
@@ -643,7 +643,7 @@ static void tls_hw_sk_destruct(struct sock *sk)
 
        ctx->sk_destruct(sk);
        /* Free ctx */
-       kfree(ctx);
+       tls_ctx_free(ctx);
        icsk->icsk_ulp_data = NULL;
 }