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 6568CA09D3; Thu, 12 Nov 2020 18:06:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B405266DA; Thu, 12 Nov 2020 18:06:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id 727655B30 for ; Thu, 12 Nov 2020 18:06:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605200790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xAhFEHy00bUuPsJJUYbOXsmz/j6QRbhvJx9vOxgPV7o=; b=SRwkViG4Oi25d7+6j0ReZxKf84N6DGBuVe8C5Qm0QFjHRIkJKYZNZfR8MZWSJwWozfz/aI Zri496aTMDxPcPSuYXTtWykteBoIcVeiL/bLksSiELqvmDACKZ/BWfObEA4jNmwdmI6dcP WqriBrqeyUVycrsPtKNF+PnPt2XZA9A= 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-396-gFYe99HDPwGpPsKx8o-RrQ-1; Thu, 12 Nov 2020 12:06:24 -0500 X-MC-Unique: gFYe99HDPwGpPsKx8o-RrQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85F0F420FE; Thu, 12 Nov 2020 17:06:23 +0000 (UTC) Received: from [10.36.110.32] (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D67845B4C9; Thu, 12 Nov 2020 17:06:21 +0000 (UTC) To: "Xia, Chenbo" , "Xueming(Steven) Li" , "dev@dpdk.org" , "Ding, Xuan" , "stephen@networkplumber.org" , NBU-Contact-Thomas Monjalon , "stable@dpdk.org" References: <20201109121630.251603-1-maxime.coquelin@redhat.com> <20201109121630.251603-4-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <37177ac1-a860-d39c-2e2c-98a9de4105a6@redhat.com> Date: Thu, 12 Nov 2020 18:06:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v3 3/3] vhost: fix fd leak in kick setup 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" On 11/11/20 8:57 AM, Xia, Chenbo wrote: > Hi Xueming & Maxime, > >> -----Original Message----- >> From: Xueming(Steven) Li >> Sent: Wednesday, November 11, 2020 2:02 PM >> To: Maxime Coquelin ; dev@dpdk.org; Ding, Xuan >> ; stephen@networkplumber.org; NBU-Contact-Thomas >> Monjalon ; stable@dpdk.org; Xia, Chenbo >> >> Subject: RE: [dpdk-dev] [PATCH v3 3/3] vhost: fix fd leak in kick setup >> >> Hi Maxime, >> >> Near end of this function, if vhost_check_queue_inflights_packed() and >> vhost_check_queue_inflights_split() return with error, is the fd expected >> to be >> closed by closing vq? > > I thought about this before. In theory, it will not cause fd leak because the fd > is saved in vq. It will be closed upon next kick msg or vhost device destroy. But > thinking it again, maybe it's better to close it now since anyway it's useless now😊 > > What do you think? I did it on purpose, as indeed it is saved in the vq metadata at that stage. The goal of the series being to avoid leaks, I think the patch does what is necessary. There is a function to cleanup the FDs and memory saved in the metadata, so let it be done there. Thanks, Maxime > Thanks, > Chenbo > >> >>> -----Original Message----- >>> From: dev On Behalf Of Maxime Coquelin >>> Sent: Monday, November 9, 2020 8:17 PM >>> To: dev@dpdk.org; xuan.ding@intel.com; stephen@networkplumber.org; >>> NBU-Contact-Thomas Monjalon ; stable@dpdk.org; >>> chenbo.xia@intel.com >>> Cc: Maxime Coquelin >>> Subject: [dpdk-dev] [PATCH v3 3/3] vhost: fix fd leak in kick setup >>> >>> This patch fixes a file descriptor leak which happens in the error path >> of >>> vhost_user_set_vring_kick(). >>> >>> Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Maxime Coquelin >>> Reviewed-by: Chenbo Xia >>> --- >>> lib/librte_vhost/vhost_user.c | 6 +++++- >>> 1 file changed, 5 insertions(+), 1 deletion(-) >>> >>> diff --git a/lib/librte_vhost/vhost_user.c >> b/lib/librte_vhost/vhost_user.c index >>> 94b066f0b9..f3b2adabac 100644 >>> --- a/lib/librte_vhost/vhost_user.c >>> +++ b/lib/librte_vhost/vhost_user.c >>> @@ -1855,8 +1855,12 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, >>> struct VhostUserMsg *msg, >>> >>> /* Interpret ring addresses only when ring is started. */ >>> dev = translate_ring_addresses(dev, file.index); >>> - if (!dev) >>> + if (!dev) { >>> + if (file.fd != VIRTIO_INVALID_EVENTFD) >>> + close(file.fd); >>> + >>> return RTE_VHOST_MSG_RESULT_ERR; >>> + } >>> >>> *pdev = dev; >>> >>> -- >>> 2.26.2 >