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 522A4A04B6; Tue, 12 Nov 2019 16:20:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 91A76397D; Tue, 12 Nov 2019 16:19:46 +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 966593772 for ; Tue, 12 Nov 2019 16:19:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573571982; 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=DuEOZ8ey6qXUjTwGnpO4VDChRnEMcWCMt52Ed7gshR8=; b=SI+0iShQvIhElgYJ0JU4L4N3Fp3MWIxxcBwBp+XzaC3Gc1jv9r2xXUlTZDyeqoq8jNrp6k sBokeGa3TR9KyKBA1Svhjz+vhVe9lBE6r1MnTa2kIyy1vFLDzk7/OynRwUG9TMMNQOBWEY y/3bgU1Xqy+NsZqaPKyl10nym9O6dkE= 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-69-q99tKhwENju75ub4WDrKgA-1; Tue, 12 Nov 2019 10:19:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80374134EF4; Tue, 12 Nov 2019 15:19:38 +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 94556100EBCC; Tue, 12 Nov 2019 15:19:34 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, stable@dpdk.org Cc: Maxime Coquelin , Jason Wang Date: Tue, 12 Nov 2019 16:19:31 +0100 Message-Id: <20191112151932.27470-1-maxime.coquelin@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: q99tKhwENju75ub4WDrKgA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [v18.11 PATCH v2 1/2] 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 5552f8bbfb..457e62d97e 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -346,6 +346,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =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) { @@ -358,6 +360,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09} =20 =09if (vq_is_packed(dev)) { +=09=09if (vq->shadow_used_packed) +=09=09=09rte_free(vq->shadow_used_packed); =09=09vq->shadow_used_packed =3D rte_malloc(NULL, =09=09=09=09vq->size * =09=09=09=09sizeof(struct vring_used_elem_packed), @@ -369,6 +373,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09} =20 =09} else { +=09=09if (vq->shadow_used_split) +=09=09=09rte_free(vq->shadow_used_split); =09=09vq->shadow_used_split =3D rte_malloc(NULL, =09=09=09=09vq->size * sizeof(struct vring_used_elem), =09=09=09=09RTE_CACHE_LINE_SIZE); @@ -379,6 +385,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09} =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