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 AC48EA04B5 for ; Tue, 3 Dec 2019 19:28:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A2CCF235; Tue, 3 Dec 2019 19:28:45 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 5F22F1BF94 for ; Tue, 3 Dec 2019 19:28:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575397722; 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=TnTXxO0eA9MB8MxNXoEskmazrAMSSCzSlaZyT7KoTd0=; b=G4yJjv33++GDRtb0hMMAgdHqTM0zS+pwHOBMGXGq1VC4+kTYqRDPVcHh6kNQVNsmeocKXy a+UAWY8TSY3HKPGyqR67kyr6/x57Pp6fP2YNbd6JMXs10E3VlTTdwrTqij1o74XdUSCNrY c//+YjWDGUnRsBrpkbWX3k1NKShRnjI= 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-356-ZAOWo2uZMm6JbN_N305I7A-1; Tue, 03 Dec 2019 13:28:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53ACE100551A; Tue, 3 Dec 2019 18:28:40 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 473FE5C3FA; Tue, 3 Dec 2019 18:28:39 +0000 (UTC) From: Kevin Traynor To: Jim Harris Cc: Anatoly Burakov , dpdk stable Date: Tue, 3 Dec 2019 18:26:47 +0000 Message-Id: <20191203182714.17297-38-ktraynor@redhat.com> In-Reply-To: <20191203182714.17297-1-ktraynor@redhat.com> References: <20191203182714.17297-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: ZAOWo2uZMm6JbN_N305I7A-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'vfio: fix leak with multiprocess' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/10/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/f41e4005bc87dd5559= 5a457e6ccd4667ea31caed Thanks. Kevin. --- >From f41e4005bc87dd55595a457e6ccd4667ea31caed Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 16 Aug 2019 05:13:42 -0700 Subject: [PATCH] vfio: fix leak with multiprocess [ upstream commit 773a860aef951727ea0c5af0f83e15fb0e24e03d ] The code checks both rte_mp_request_sync() return code and that the number of messages in the reply equals 1. If rte_mp_request_sync() succeeds but there was more than one message, those messages would get leaked. Found via code review by Anatoly Burakov of patches that used the vhost code as a template for using rte_mp_request_sync(). Fixes: 83a73c5fef66 ("vfio: use generic multi-process channel") Reported-by: Anatoly Burakov Signed-off-by: Jim Harris Acked-by: Anatoly Burakov --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxa= pp/eal/eal_vfio.c index 830b320d7..48d2abafa 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -264,5 +264,5 @@ vfio_open_group_fd(int iommu_group_num) =09char filename[PATH_MAX]; =09struct rte_mp_msg mp_req, *mp_rep; -=09struct rte_mp_reply mp_reply; +=09struct rte_mp_reply mp_reply =3D {0}; =09struct timespec ts =3D {.tv_sec =3D 5, .tv_nsec =3D 0}; =09struct vfio_mp_param *p =3D (struct vfio_mp_param *)mp_req.param; @@ -320,7 +320,7 @@ vfio_open_group_fd(int iommu_group_num) =09=09=09vfio_group_fd =3D 0; =09=09} -=09=09free(mp_reply.msgs); =09} =20 +=09free(mp_reply.msgs); =09if (vfio_group_fd < 0) =09=09RTE_LOG(ERR, EAL, " cannot request group fd\n"); @@ -554,5 +554,5 @@ vfio_sync_default_container(void) { =09struct rte_mp_msg mp_req, *mp_rep; -=09struct rte_mp_reply mp_reply; +=09struct rte_mp_reply mp_reply =3D {0}; =09struct timespec ts =3D {.tv_sec =3D 5, .tv_nsec =3D 0}; =09struct vfio_mp_param *p =3D (struct vfio_mp_param *)mp_req.param; @@ -584,6 +584,6 @@ vfio_sync_default_container(void) =09=09if (p->result =3D=3D SOCKET_OK) =09=09=09iommu_type_id =3D p->iommu_type_id; -=09=09free(mp_reply.msgs); =09} +=09free(mp_reply.msgs); =09if (iommu_type_id < 0) { =09=09RTE_LOG(ERR, EAL, "Could not get IOMMU type for default container\n"= ); @@ -1023,5 +1023,5 @@ vfio_get_default_container_fd(void) { =09struct rte_mp_msg mp_req, *mp_rep; -=09struct rte_mp_reply mp_reply; +=09struct rte_mp_reply mp_reply =3D {0}; =09struct timespec ts =3D {.tv_sec =3D 5, .tv_nsec =3D 0}; =09struct vfio_mp_param *p =3D (struct vfio_mp_param *)mp_req.param; @@ -1051,7 +1051,7 @@ vfio_get_default_container_fd(void) =09=09=09return mp_rep->fds[0]; =09=09} -=09=09free(mp_reply.msgs); =09} =20 +=09free(mp_reply.msgs); =09RTE_LOG(ERR, EAL, " cannot request default container fd\n"); =09return -1; @@ -1129,5 +1129,5 @@ rte_vfio_get_container_fd(void) =09int ret, vfio_container_fd; =09struct rte_mp_msg mp_req, *mp_rep; -=09struct rte_mp_reply mp_reply; +=09struct rte_mp_reply mp_reply =3D {0}; =09struct timespec ts =3D {.tv_sec =3D 5, .tv_nsec =3D 0}; =09struct vfio_mp_param *p =3D (struct vfio_mp_param *)mp_req.param; @@ -1183,7 +1183,7 @@ rte_vfio_get_container_fd(void) =09=09=09return vfio_container_fd; =09=09} -=09=09free(mp_reply.msgs); =09} =20 +=09free(mp_reply.msgs); =09RTE_LOG(ERR, EAL, " cannot request container fd\n"); =09return -1; --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-03 17:29:54.023200810 +0000 +++ 0038-vfio-fix-leak-with-multiprocess.patch=092019-12-03 17:29:51.763749= 682 +0000 @@ -1 +1 @@ -From 773a860aef951727ea0c5af0f83e15fb0e24e03d Mon Sep 17 00:00:00 2001 +From f41e4005bc87dd55595a457e6ccd4667ea31caed Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 773a860aef951727ea0c5af0f83e15fb0e24e03d ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -20 +21 @@ - lib/librte_eal/linux/eal/eal_vfio.c | 16 ++++++++-------- + lib/librte_eal/linuxapp/eal/eal_vfio.c | 16 ++++++++-------- @@ -23,5 +24,5 @@ -diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/ea= l/eal_vfio.c -index 501c74f23..d9541b122 100644 ---- a/lib/librte_eal/linux/eal/eal_vfio.c -+++ b/lib/librte_eal/linux/eal/eal_vfio.c -@@ -265,5 +265,5 @@ vfio_open_group_fd(int iommu_group_num) +diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linux= app/eal/eal_vfio.c +index 830b320d7..48d2abafa 100644 +--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c ++++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c +@@ -264,5 +264,5 @@ vfio_open_group_fd(int iommu_group_num) @@ -34 +35 @@ -@@ -321,7 +321,7 @@ vfio_open_group_fd(int iommu_group_num) +@@ -320,7 +320,7 @@ vfio_open_group_fd(int iommu_group_num) @@ -43 +44 @@ -@@ -555,5 +555,5 @@ vfio_sync_default_container(void) +@@ -554,5 +554,5 @@ vfio_sync_default_container(void) @@ -50 +51 @@ -@@ -585,6 +585,6 @@ vfio_sync_default_container(void) +@@ -584,6 +584,6 @@ vfio_sync_default_container(void) @@ -58 +59 @@ -@@ -1022,5 +1022,5 @@ vfio_get_default_container_fd(void) +@@ -1023,5 +1023,5 @@ vfio_get_default_container_fd(void) @@ -65 +66 @@ -@@ -1050,7 +1050,7 @@ vfio_get_default_container_fd(void) +@@ -1051,7 +1051,7 @@ vfio_get_default_container_fd(void) @@ -74 +75 @@ -@@ -1128,5 +1128,5 @@ rte_vfio_get_container_fd(void) +@@ -1129,5 +1129,5 @@ rte_vfio_get_container_fd(void) @@ -81 +82 @@ -@@ -1182,7 +1182,7 @@ rte_vfio_get_container_fd(void) +@@ -1183,7 +1183,7 @@ rte_vfio_get_container_fd(void)