diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-06-23 06:15:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-23 14:19:27 -0400 |
commit | ac55cd619335c577f29eea599a6a35b6b48797e8 (patch) | |
tree | ee7e30c96b95f528ac7e5299f159d49a6b5490b4 /net/tls/tls_main.c | |
parent | 93bbbfbb4a5aa32a2375a86f3a23e48ea75e05db (diff) |
tls: return -EFAULT if copy_to_user() fails
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@oracle.com>
Acked-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tls/tls_main.c')
-rw-r--r-- | net/tls/tls_main.c | 10 |
1 files changed, 6 insertions, 4 deletions
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, | |||
273 | } | 273 | } |
274 | 274 | ||
275 | if (len == sizeof(crypto_info)) { | 275 | if (len == sizeof(crypto_info)) { |
276 | rc = copy_to_user(optval, crypto_info, sizeof(*crypto_info)); | 276 | if (copy_to_user(optval, crypto_info, sizeof(*crypto_info))) |
277 | rc = -EFAULT; | ||
277 | goto out; | 278 | goto out; |
278 | } | 279 | } |
279 | 280 | ||
@@ -293,9 +294,10 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval, | |||
293 | memcpy(crypto_info_aes_gcm_128->iv, ctx->iv, | 294 | memcpy(crypto_info_aes_gcm_128->iv, ctx->iv, |
294 | TLS_CIPHER_AES_GCM_128_IV_SIZE); | 295 | TLS_CIPHER_AES_GCM_128_IV_SIZE); |
295 | release_sock(sk); | 296 | release_sock(sk); |
296 | rc = copy_to_user(optval, | 297 | if (copy_to_user(optval, |
297 | crypto_info_aes_gcm_128, | 298 | crypto_info_aes_gcm_128, |
298 | sizeof(*crypto_info_aes_gcm_128)); | 299 | sizeof(*crypto_info_aes_gcm_128))) |
300 | rc = -EFAULT; | ||
299 | break; | 301 | break; |
300 | } | 302 | } |
301 | default: | 303 | default: |