From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AED1FA04B6; Tue, 12 Nov 2019 16:21:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAAAA1BE9A; Tue, 12 Nov 2019 16:19:57 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id C786C58C3 for ; Tue, 12 Nov 2019 16:19:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573571991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wUV3RU6e8f3t5fz2Ca/mBlQa8BKpZN3Fd5QtD1nxk0s=; b=J6NndOjvfcsuApLQqC0iGfidXIDbgh4gsmCwoQMAfuAYEbydOML3HLA1LpL8r6YSyjZ1ar HskucaLg5L4XIm9WR2+SsmbWRVLFwk2ENnLfrknNoySpkOHPjTrPZV5agZ19/s58aFfFB4 w4pgrN1Hbu7NLJGu7UhA+d+z73bOhkI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-FwbJZNW0NoiiC4HvodTzIg-1; Tue, 12 Nov 2019 10:19:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D7DF1007286; Tue, 12 Nov 2019 15:19:47 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-39.ams2.redhat.com [10.36.112.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7FA35DDA8; Tue, 12 Nov 2019 15:19:42 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, stable@dpdk.org Cc: Maxime Coquelin , Jason Wang Date: Tue, 12 Nov 2019 16:19:26 +0100 Message-Id: <20191112151927.27418-3-maxime.coquelin@redhat.com> In-Reply-To: <20191112151927.27418-1-maxime.coquelin@redhat.com> References: <20191112151927.27418-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: FwbJZNW0NoiiC4HvodTzIg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [v17.11 PATCH v2 3/4] vhost: fix possible denial of service on SET_VRING_NUM X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" vhost_user_set_vring_num() performs multiple allocations without checking whether data were previously allocated. It may cause a denial of service because of the memory leaks that happen if a malicious vhost-user master keeps sending VHOST_USER_SET_VRING_NUM request until the slave runs out of memory. This issue has been assigned CVE-2019-14818 Reported-by: Jason Wang Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 9773691097..781734e9e3 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -262,6 +262,8 @@ vhost_user_set_vring_num(struct virtio_net *dev, =09=09vq->nr_zmbuf =3D 0; =09=09vq->last_zmbuf_idx =3D 0; =09=09vq->zmbuf_size =3D vq->size; +=09=09if (vq->zmbufs) +=09=09=09rte_free(vq->zmbufs); =09=09vq->zmbufs =3D rte_zmalloc(NULL, vq->zmbuf_size * =09=09=09=09=09 sizeof(struct zcopy_mbuf), 0); =09=09if (vq->zmbufs =3D=3D NULL) { @@ -271,7 +273,8 @@ vhost_user_set_vring_num(struct virtio_net *dev, =09=09=09dev->dequeue_zero_copy =3D 0; =09=09} =09} - +=09if (vq->shadow_used_ring) +=09=09rte_free(vq->shadow_used_ring); =09vq->shadow_used_ring =3D rte_malloc(NULL, =09=09=09=09vq->size * sizeof(struct vring_used_elem), =09=09=09=09RTE_CACHE_LINE_SIZE); @@ -281,6 +284,8 @@ vhost_user_set_vring_num(struct virtio_net *dev, =09=09return -1; =09} =20 +=09if (vq->batch_copy_elems) +=09=09rte_free(vq->batch_copy_elems); =09vq->batch_copy_elems =3D rte_malloc(NULL, =09=09=09=09vq->size * sizeof(struct batch_copy_elem), =09=09=09=09RTE_CACHE_LINE_SIZE); --=20 2.21.0