Message ID | 20221110080131.1919453-1-liaoyu15@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net/tls: Fix memory leak in tls_enc_skb() | expand |
On 10/11/2022 10:01, Yu Liao wrote: > 'aead_req' is allocated in tls_alloc_aead_request(), but not freed > in switch case 'default'. This commit fixes the potential memory leak > by freeing 'aead_req' under the situation. > > Fixes: ea7a9d88ba21 ("net/tls: Use cipher sizes structs") > Signed-off-by: Yu Liao <liaoyu15@huawei.com> > --- > net/tls/tls_device_fallback.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c > index cdb391a8754b..efffceee129f 100644 > --- a/net/tls/tls_device_fallback.c > +++ b/net/tls/tls_device_fallback.c > @@ -346,7 +346,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx, > salt = tls_ctx->crypto_send.aes_gcm_256.salt; > break; > default: > - return NULL; > + goto free_req; > } > cipher_sz = &tls_cipher_size_desc[tls_ctx->crypto_send.info.cipher_type]; > buf_len = cipher_sz->salt + cipher_sz->iv + TLS_AAD_SPACE_SIZE + Thanks Yu! Please also fix tls_sw_fallback_init(), it has the same issue.
diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c index cdb391a8754b..efffceee129f 100644 --- a/net/tls/tls_device_fallback.c +++ b/net/tls/tls_device_fallback.c @@ -346,7 +346,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx, salt = tls_ctx->crypto_send.aes_gcm_256.salt; break; default: - return NULL; + goto free_req; } cipher_sz = &tls_cipher_size_desc[tls_ctx->crypto_send.info.cipher_type]; buf_len = cipher_sz->salt + cipher_sz->iv + TLS_AAD_SPACE_SIZE +
'aead_req' is allocated in tls_alloc_aead_request(), but not freed in switch case 'default'. This commit fixes the potential memory leak by freeing 'aead_req' under the situation. Fixes: ea7a9d88ba21 ("net/tls: Use cipher sizes structs") Signed-off-by: Yu Liao <liaoyu15@huawei.com> --- net/tls/tls_device_fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)