diff options
Diffstat (limited to 'net/tls/tls_main.c')
| -rw-r--r-- | net/tls/tls_main.c | 36 | 
1 files changed, 19 insertions, 17 deletions
| diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 9547cea0ce3b..fc81ae18cc44 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -293,11 +293,8 @@ static void tls_sk_proto_close(struct sock *sk, long timeout)  #endif  	} -	if (ctx->rx_conf == TLS_SW) { -		kfree(ctx->rx.rec_seq); -		kfree(ctx->rx.iv); +	if (ctx->rx_conf == TLS_SW)  		tls_sw_free_resources_rx(sk); -	}  #ifdef CONFIG_TLS_DEVICE  	if (ctx->rx_conf == TLS_HW) @@ -493,27 +490,32 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,  	switch (crypto_info->cipher_type) {  	case TLS_CIPHER_AES_GCM_128: +		optsize = sizeof(struct tls12_crypto_info_aes_gcm_128); +		break;  	case TLS_CIPHER_AES_GCM_256: { -		optsize = crypto_info->cipher_type == TLS_CIPHER_AES_GCM_128 ? -			sizeof(struct tls12_crypto_info_aes_gcm_128) : -			sizeof(struct tls12_crypto_info_aes_gcm_256); -		if (optlen != optsize) { -			rc = -EINVAL; -			goto err_crypto_info; -		} -		rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info), -				    optlen - sizeof(*crypto_info)); -		if (rc) { -			rc = -EFAULT; -			goto err_crypto_info; -		} +		optsize = sizeof(struct tls12_crypto_info_aes_gcm_256);  		break;  	} +	case TLS_CIPHER_AES_CCM_128: +		optsize = sizeof(struct tls12_crypto_info_aes_ccm_128); +		break;  	default:  		rc = -EINVAL;  		goto err_crypto_info;  	} +	if (optlen != optsize) { +		rc = -EINVAL; +		goto err_crypto_info; +	} + +	rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info), +			    optlen - sizeof(*crypto_info)); +	if (rc) { +		rc = -EFAULT; +		goto err_crypto_info; +	} +  	if (tx) {  #ifdef CONFIG_TLS_DEVICE  		rc = tls_set_device_offload(sk, ctx); |