From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D13C0F937 for ; Thu, 9 Feb 2017 12:41:24 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP; 09 Feb 2017 03:41:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,349,1484035200"; d="scan'208";a="63698832" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga006.fm.intel.com with ESMTP; 09 Feb 2017 03:41:22 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.44]) by IRSMSX102.ger.corp.intel.com ([169.254.2.230]) with mapi id 14.03.0248.002; Thu, 9 Feb 2017 11:41:22 +0000 From: "Burakov, Anatoly" To: Patrick MacArthur , "dev@dpdk.org" Thread-Topic: [PATCH] vfio: fix file descriptor leak in multi-process applications Thread-Index: AQHSeCjPb22/DPcuZkCXDuug2WsVJKFgonQA Date: Thu, 9 Feb 2017 11:41:21 +0000 Message-ID: References: <20170126230521.28314-1-patrick@patrickmacarthur.net> In-Reply-To: <20170126230521.28314-1-patrick@patrickmacarthur.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_PUBLIC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2RlNjQxODctN2Q5ZS00NjRhLWI0NTYtM2I3M2E3YmRhNzUwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJoQXpJeWo3U1IxN3dNQ1VBRFpyM2lPcHBCaHJXTHNzQUJ2bGZsRW1Pcm5jPSJ9 x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vfio: fix file descriptor leak in multi-process applications 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: , X-List-Received-Date: Thu, 09 Feb 2017 11:41:25 -0000 > -----Original Message----- > From: Patrick MacArthur [mailto:patrick@patrickmacarthur.net] > Sent: Thursday, January 26, 2017 11:05 PM > To: dev@dpdk.org; Burakov, Anatoly > Cc: Patrick MacArthur > Subject: [PATCH] vfio: fix file descriptor leak in multi-process applicat= ions >=20 > When a secondary process wants access to the VFIO container file descript= or, > the primary process calls vfio_get_container_fd() which always opens an > entirely new file descriptor on /dev/vfio/vfio. > However, once the file descriptor has been passed to the subprocess, it i= s > effectively duplicated, meaning that the copy of the file descriptor in t= he > primary process is no longer needed. However, the primary process does > not close the duplicate fd, which results in a resource leak. >=20 > This can be reproduced by starting a primary process with a small > RLIMIT_NOFILE limit configured to use VFIO for at least one device, and > repeatedly launching secondary processes until the file descriptor limit = is > exceeded. >=20 > Fix the resource leak by closing the local vfio container file descriptor= after > passing it to the secondary process. >=20 > Fixes: 2f4adfad0a69 ("vfio: add multiprocess support") > Signed-off-by: Patrick MacArthur > --- > lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c > b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c > index 00cf919b64d0..fb4a2f84b180 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c > @@ -301,6 +301,7 @@ vfio_mp_sync_thread(void __rte_unused * arg) > vfio_mp_sync_send_request(conn_sock, > SOCKET_ERR); > else > vfio_mp_sync_send_fd(conn_sock, fd); > + close(fd); > break; > case SOCKET_REQ_GROUP: > /* wait for group number */ > -- > 2.9.3 Acked-by: Anatoly Burakov