patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: stable@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	Xiaolong Ye <xiaolong.ye@intel.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-stable] [PATCH v19.11 5/6] vhost: fix potential memory space leak
Date: Mon, 18 May 2020 14:19:12 +0100	[thread overview]
Message-ID: <20200518131913.716252-6-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20200518131913.716252-1-ferruh.yigit@intel.com>

From: Xiaolong Ye <xiaolong.ye@intel.com>

A malicious container which has direct access to the vhost-user socket
can keep sending VHOST_USER_GET_INFLIGHT_FD messages which may cause
leaking resources until resulting a DOS. Fix it by unmapping the
dev->inflight_info->addr before assigning new mapped addr to it.

Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing")
Cc: stable@dpdk.org

This issue has been assigned CVE-2020-10726

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/vhost_user.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index d19614265b..2a4ba205cf 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1433,6 +1433,11 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
 	}
 	memset(addr, 0, mmap_size);
 
+	if (dev->inflight_info->addr) {
+		munmap(dev->inflight_info->addr, dev->inflight_info->size);
+		dev->inflight_info->addr = NULL;
+	}
+
 	dev->inflight_info->addr = addr;
 	dev->inflight_info->size = msg->payload.inflight.mmap_size = mmap_size;
 	dev->inflight_info->fd = msg->fds[0] = fd;
@@ -1517,8 +1522,10 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
 		}
 	}
 
-	if (dev->inflight_info->addr)
+	if (dev->inflight_info->addr) {
 		munmap(dev->inflight_info->addr, dev->inflight_info->size);
+		dev->inflight_info->addr = NULL;
+	}
 
 	addr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
 		    fd, mmap_offset);
-- 
2.25.2


  parent reply	other threads:[~2020-05-18 13:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 13:19 [dpdk-stable] [PATCH v19.11 0/6] Fix vhost security issues Ferruh Yigit
2020-05-18 13:19 ` [dpdk-stable] [PATCH v19.11 1/6] vhost: check log mmap offset and size overflow Ferruh Yigit
2020-05-18 13:19 ` [dpdk-stable] [PATCH v19.11 2/6] vhost: fix vring index check Ferruh Yigit
2020-05-18 13:19 ` [dpdk-stable] [PATCH v19.11 3/6] vhost/crypto: validate keys lengths Ferruh Yigit
2020-05-18 13:19 ` [dpdk-stable] [PATCH v19.11 4/6] vhost: fix translated address not checked Ferruh Yigit
2020-05-18 13:19 ` Ferruh Yigit [this message]
2020-05-18 13:19 ` [dpdk-stable] [PATCH v19.11 6/6] vhost: fix potential fd leak Ferruh Yigit

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=20200518131913.716252-6-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=xiaolong.ye@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).