From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Hajnoczi Subject: [PATCH 5/8] vhost: reject invalid log base mmap_offset values Date: Mon, 5 Feb 2018 12:16:39 +0000 Message-ID: <20180205121642.26428-6-stefanha@redhat.com> References: <20180205121642.26428-1-stefanha@redhat.com> Cc: Maxime Coquelin , Yuanhan Liu , Stefan Hajnoczi To: dev@dpdk.org Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 1FA1B1B335 for ; Mon, 5 Feb 2018 13:17:16 +0100 (CET) In-Reply-To: <20180205121642.26428-1-stefanha@redhat.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If the log base mmap_offset is larger than mmap_size then it points outside the mmap region. We must not write to memory outside the mmap region, so validate mmap_offset in vhost_user_set_log_base(). Signed-off-by: Stefan Hajnoczi --- lib/librte_vhost/vhost_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 48b493d70..fd47404ce 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1005,6 +1005,15 @@ vhost_user_set_log_base(struct virtio_net *dev, 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) { + RTE_LOG(ERR, VHOST_CONFIG, + "log offset %#"PRIx64" exceeds log size %#"PRIx64"\n", + off, size); + return -1; + } + RTE_LOG(INFO, VHOST_CONFIG, "log mmap size: %"PRId64", offset: %"PRId64"\n", size, off); -- 2.14.3