lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170623161208.GA68369@davejwatson-mba.local>
Date:   Fri, 23 Jun 2017 09:12:08 -0700
From:   Dave Watson <davejwatson@...com>
To:     Dan Carpenter <dan.carpenter@...cle.com>
CC:     Aviad Yehezkel <aviadye@...lanox.com>,
        Ilya Lesokhin <ilyal@...lanox.com>,
        "David S. Miller" <davem@...emloft.net>, <netdev@...r.kernel.org>,
        <kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH -net] tls: return -EFAULT if copy_to_user() fails

On 06/23/17 01:15 PM, Dan Carpenter wrote:
> The copy_to_user() function returns the number of bytes remaining but we
> want to return -EFAULT here.
> 
> Fixes: 3c4d7559159b ("tls: kernel TLS support")
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>

Acked-by: Dave Watson <davejwatson@...com>

Yes, -EFAULT seems like the correct choice here, the return from
copy_to_user isn't useful.  Thanks

> 
> diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
> index 2ebc328bda96..a03130a47b85 100644
> --- a/net/tls/tls_main.c
> +++ b/net/tls/tls_main.c
> @@ -273,7 +273,8 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
>  	}
>  
>  	if (len == sizeof(crypto_info)) {
> -		rc = copy_to_user(optval, crypto_info, sizeof(*crypto_info));
> +		if (copy_to_user(optval, crypto_info, sizeof(*crypto_info)))
> +			rc = -EFAULT;
>  		goto out;
>  	}
>  
> @@ -293,9 +294,10 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
>  		memcpy(crypto_info_aes_gcm_128->iv, ctx->iv,
>  		       TLS_CIPHER_AES_GCM_128_IV_SIZE);
>  		release_sock(sk);
> -		rc = copy_to_user(optval,
> -				  crypto_info_aes_gcm_128,
> -				  sizeof(*crypto_info_aes_gcm_128));
> +		if (copy_to_user(optval,
> +				 crypto_info_aes_gcm_128,
> +				 sizeof(*crypto_info_aes_gcm_128)))
> +			rc = -EFAULT;
>  		break;
>  	}
>  	default:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ