patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v18.11 0/3] Fix vhost security issues
@ 2020-05-18 13:18 Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 1/3] vhost: check log mmap offset and size overflow Ferruh Yigit
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ferruh Yigit @ 2020-05-18 13:18 UTC (permalink / raw)
  To: stable; +Cc: Ferruh Yigit, Maxime Coquelin

From: Maxime Coquelin <maxime.coquelin@redhat.com>

Maxime Coquelin (3):
  vhost: check log mmap offset and size overflow
  vhost: fix vring index check
  vhost/crypto: validate keys lengths

 lib/librte_vhost/vhost_crypto.c | 17 +++++++++++++++++
 lib/librte_vhost/vhost_user.c   |  8 ++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.25.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-stable] [PATCH v18.11 1/3] vhost: check log mmap offset and size overflow
  2020-05-18 13:18 [dpdk-stable] [PATCH v18.11 0/3] Fix vhost security issues Ferruh Yigit
@ 2020-05-18 13:18 ` Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 2/3] vhost: fix vring index check Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 3/3] vhost/crypto: validate keys lengths Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2020-05-18 13:18 UTC (permalink / raw)
  To: stable; +Cc: Ferruh Yigit, Maxime Coquelin, Ilja Van Sprundel, Xiaolong Ye

From: Maxime Coquelin <maxime.coquelin@redhat.com>

vhost_user_set_log_base() is a message handler that is
called to handle the VHOST_USER_SET_LOG_BASE message.
Its payload contains a 64 bit size and offset. Both are
added up and used as a size when calling mmap().

There is no integer overflow check. If an integer overflow
occurs a smaller memory map would be created than
requested. Since the returned mapping is mapped as writable
and used for logging, a memory corruption could occur.

Fixes: fbc4d248b198 ("vhost: fix offset while mmaping log base address")
Cc: stable@dpdk.org

This issue has been assigned CVE-2020-10722

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Reviewed-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
---
 lib/librte_vhost/vhost_user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 2f4bbb342d..8d78c11b9b 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1595,10 +1595,10 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
 	size = msg->payload.log.mmap_size;
 	off  = msg->payload.log.mmap_offset;
 
-	/* Don't allow mmap_offset to point outside the mmap region */
-	if (off > size) {
+	/* Check for mmap size and offset overflow. */
+	if (off >= -size) {
 		RTE_LOG(ERR, VHOST_CONFIG,
-			"log offset %#"PRIx64" exceeds log size %#"PRIx64"\n",
+			"log offset %#"PRIx64" and log size %#"PRIx64" overflow\n",
 			off, size);
 		return VH_RESULT_ERR;
 	}
-- 
2.25.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-stable] [PATCH v18.11 2/3] vhost: fix vring index check
  2020-05-18 13:18 [dpdk-stable] [PATCH v18.11 0/3] Fix vhost security issues Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 1/3] vhost: check log mmap offset and size overflow Ferruh Yigit
@ 2020-05-18 13:18 ` Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 3/3] vhost/crypto: validate keys lengths Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2020-05-18 13:18 UTC (permalink / raw)
  To: stable; +Cc: Ferruh Yigit, Maxime Coquelin, Ilja Van Sprundel, Xiaolong Ye

From: Maxime Coquelin <maxime.coquelin@redhat.com>

vhost_user_check_and_alloc_queue_pair() is used to extract
a vring index from a payload. This function validates the
index and is called early on in when performing message
handling. Most message handlers depend on it correctly
validating the vring index.

Depending on the message type the vring index is in
different parts of the payload. The function contains a
switch/case for each type and copies the index. This is
stored in a uint16. This index is then validated. Depending
on the message, the source index is an unsigned int. If
integer truncation occurs (uint->uint16) the top 16 bits
of the index are never validated.

When they are used later on  (e.g. in
vhost_user_set_vring_num() or vhost_user_set_vring_addr())
it can lead to out of bound indexing. The out of bound
indexed data gets written to, and hence this can cause
memory corruption.

This patch fixes this vulnerability by declaring vring
index as an unsigned int in
vhost_user_check_and_alloc_queue_pair().

Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
Cc: stable@dpdk.org

This issue has been assigned CVE-2020-10723

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Reviewed-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
---
 lib/librte_vhost/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 8d78c11b9b..e4f72ba876 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2062,7 +2062,7 @@ static int
 vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,
 			struct VhostUserMsg *msg)
 {
-	uint16_t vring_idx;
+	uint32_t vring_idx;
 
 	switch (msg->request.master) {
 	case VHOST_USER_SET_VRING_KICK:
-- 
2.25.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-stable] [PATCH v18.11 3/3] vhost/crypto: validate keys lengths
  2020-05-18 13:18 [dpdk-stable] [PATCH v18.11 0/3] Fix vhost security issues Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 1/3] vhost: check log mmap offset and size overflow Ferruh Yigit
  2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 2/3] vhost: fix vring index check Ferruh Yigit
@ 2020-05-18 13:18 ` Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2020-05-18 13:18 UTC (permalink / raw)
  To: stable; +Cc: Ferruh Yigit, Maxime Coquelin, Ilja Van Sprundel, Xiaolong Ye

From: Maxime Coquelin <maxime.coquelin@redhat.com>

transform_cipher_param() and transform_chain_param() handle
the payload data for the VHOST_USER_CRYPTO_CREATE_SESS
message. These payloads have to be validated, since it
could come from untrusted sources.

Two buffers and their lenghts are defined in this payload,
one the the auth key and one for the cipher key. But above
functions do not validate the key length inputs, which could
lead to read out of bounds, as buffers have static sizes of
64 bytes for the cipher key and 512 bytes for the auth key.

This patch adds necessary checks on the key length field
before being used.

Fixes: e80a98708166 ("vhost/crypto: add session message handler")
Cc: stable@dpdk.org

This issue has been assigned CVE-2020-10724

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Reviewed-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
---
 lib/librte_vhost/vhost_crypto.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_vhost/vhost_crypto.c b/lib/librte_vhost/vhost_crypto.c
index cf01c7ebe3..8934365f2f 100644
--- a/lib/librte_vhost/vhost_crypto.c
+++ b/lib/librte_vhost/vhost_crypto.c
@@ -236,6 +236,11 @@ transform_cipher_param(struct rte_crypto_sym_xform *xform,
 	if (unlikely(ret < 0))
 		return ret;
 
+	if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) {
+		VC_LOG_DBG("Invalid cipher key length\n");
+		return -VIRTIO_CRYPTO_BADMSG;
+	}
+
 	xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	xform->cipher.key.length = param->cipher_key_len;
 	if (xform->cipher.key.length > 0)
@@ -286,6 +291,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms,
 			&xform_cipher->cipher.algo);
 	if (unlikely(ret < 0))
 		return ret;
+
+	if (param->cipher_key_len > VHOST_USER_CRYPTO_MAX_CIPHER_KEY_LENGTH) {
+		VC_LOG_DBG("Invalid cipher key length\n");
+		return -VIRTIO_CRYPTO_BADMSG;
+	}
+
 	xform_cipher->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	xform_cipher->cipher.key.length = param->cipher_key_len;
 	xform_cipher->cipher.key.data = param->cipher_key_buf;
@@ -300,6 +311,12 @@ transform_chain_param(struct rte_crypto_sym_xform *xforms,
 	ret = auth_algo_transform(param->hash_algo, &xform_auth->auth.algo);
 	if (unlikely(ret < 0))
 		return ret;
+
+	if (param->auth_key_len > VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH) {
+		VC_LOG_DBG("Invalid auth key length\n");
+		return -VIRTIO_CRYPTO_BADMSG;
+	}
+
 	xform_auth->auth.digest_length = param->digest_len;
 	xform_auth->auth.key.length = param->auth_key_len;
 	xform_auth->auth.key.data = param->auth_key_buf;
-- 
2.25.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-18 13:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 13:18 [dpdk-stable] [PATCH v18.11 0/3] Fix vhost security issues Ferruh Yigit
2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 1/3] vhost: check log mmap offset and size overflow Ferruh Yigit
2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 2/3] vhost: fix vring index check Ferruh Yigit
2020-05-18 13:18 ` [dpdk-stable] [PATCH v18.11 3/3] vhost/crypto: validate keys lengths Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).