From: Dave Watson <davejwatson@fb.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Aviad Yehezkel <aviadye@mellanox.com>,
Ilya Lesokhin <ilyal@mellanox.com>,
"David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH -net] tls: return -EFAULT if copy_to_user() fails
Date: Fri, 23 Jun 2017 09:12:08 -0700 [thread overview]
Message-ID: <20170623161208.GA68369@davejwatson-mba.local> (raw)
In-Reply-To: <20170623101544.c5bvwe5cd6e46bd5@mwanda>
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@oracle.com>
Acked-by: Dave Watson <davejwatson@fb.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:
next prev parent reply other threads:[~2017-06-23 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 10:15 [PATCH -net] tls: return -EFAULT if copy_to_user() fails Dan Carpenter
2017-06-23 10:31 ` Joe Perches
2017-06-23 10:34 ` Dan Carpenter
2017-06-23 10:36 ` Dan Carpenter
2017-06-23 10:58 ` Joe Perches
2017-06-23 11:29 ` Dan Carpenter
2017-06-23 16:12 ` Dave Watson [this message]
2017-06-23 18:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170623161208.GA68369@davejwatson-mba.local \
--to=davejwatson@fb.com \
--cc=aviadye@mellanox.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=ilyal@mellanox.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox