From: Dan Carpenter <dan.carpenter@oracle.com>
To: Dave Watson <davejwatson@fb.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: [PATCH -net] tls: return -EFAULT if copy_to_user() fails
Date: Fri, 23 Jun 2017 10:15:44 +0000 [thread overview]
Message-ID: <20170623101544.c5bvwe5cd6e46bd5@mwanda> (raw)
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>
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:
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Dave Watson <davejwatson@fb.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: [PATCH -net] tls: return -EFAULT if copy_to_user() fails
Date: Fri, 23 Jun 2017 13:15:44 +0300 [thread overview]
Message-ID: <20170623101544.c5bvwe5cd6e46bd5@mwanda> (raw)
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>
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 reply other threads:[~2017-06-23 10:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 10:15 Dan Carpenter [this message]
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:31 ` Joe Perches
2017-06-23 10:34 ` Dan Carpenter
2017-06-23 10:34 ` Dan Carpenter
2017-06-23 10:36 ` Dan Carpenter
2017-06-23 10:36 ` Dan Carpenter
2017-06-23 10:58 ` Joe Perches
2017-06-23 10:58 ` Joe Perches
2017-06-23 11:29 ` Dan Carpenter
2017-06-23 11:29 ` Dan Carpenter
2017-06-23 16:12 ` Dave Watson
2017-06-23 16:12 ` Dave Watson
2017-06-23 18:20 ` David Miller
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=20170623101544.c5bvwe5cd6e46bd5@mwanda \
--to=dan.carpenter@oracle.com \
--cc=aviadye@mellanox.com \
--cc=davejwatson@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.