From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 28052A0093
	for <public@inbox.dpdk.org>; Tue, 19 May 2020 15:11:03 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 1086E1D6F0;
	Tue, 19 May 2020 15:11:03 +0200 (CEST)
Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com
 [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id 0ECA01D6E7
 for <stable@dpdk.org>; Tue, 19 May 2020 15:11:02 +0200 (CEST)
Received: by mail-wm1-f67.google.com with SMTP id h4so2992837wmb.4
 for <stable@dpdk.org>; Tue, 19 May 2020 06:11:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=67pxSG+39QQXoi/Vfu3A0xCd1uGUhqV1Bjv77yKpvH4=;
 b=TPSd939rSm7MPZeqhgAtGR2YTFiMyQ7zqpP1X+p4WIg2WxSmQNfrpHIjSqIVGoLmi1
 0F3Ti0sBEefkOtcRL9VO5ekrCYxXphe1iigmSeBnjkKP0NBj7bkD+7xfOJ5VEvo6VfcV
 bJt1WRG/bb6bjbio3VBICUcE7Deq4Jn6LRjmaLqGWJN4nyktwPAVkRoQZzdNPcoP2OZa
 7b0PPe6cWGhw1zvaMpIy0ykxPm90pZ0Jzc724RRH3txfz3m4ZJ/WIOKQ6ZxuFiOiGB9z
 407jigSWGZinsaxCNW4dzpH74g63ImgTmGQuVxfaESQAW9JlOxKzKtLEPf6Xc4TLCrv5
 njxw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=67pxSG+39QQXoi/Vfu3A0xCd1uGUhqV1Bjv77yKpvH4=;
 b=LOdXYPMtPgaI2ygAeHrAar8VLj0usFpYZgcUP3Y8oCNUX5FLBaHYXzdvaXscXIkxBQ
 WlaNvQ1IIdN1+aEIPW+PUdoh9JxR8DdHyky1qg9IcUM54DCFTdBImee0axn87oaAi+yP
 DYnTC7VOPKXoeGVBERIXwMlW6vbot4A5RUgXNX2r+CqdRQHvVz639d0lo6Ws3/uDlJK6
 8hdK+Q557TgK6/zhL+3s5OtuvFAfw3UBDyNTzYg18j9873XhhSLUBF+F9xhn5y4c6dc/
 DmoonbCNuhCuaYBMFOMN40+gUKgb2+Do1JVtqP1n/kWb0AwNNQfyIgZhWMJv/OTLwT4k
 Wk8A==
X-Gm-Message-State: AOAM53170XfIdJbGkJdjeEqaQs6k+o40ggJ5rDi+YWcs3M49DyhNut3y
 F0o3e9MKewLwtKyNqa+q5a0=
X-Google-Smtp-Source: ABdhPJynHUWA8kgnY0XK8y1Km0LR/wFvzqhYRSEDmM083jK6nzI0Tuo1kEgnTtsnCwZqKdRd1aw6LQ==
X-Received: by 2002:a7b:c0d7:: with SMTP id s23mr5433249wmh.18.1589893861743; 
 Tue, 19 May 2020 06:11:01 -0700 (PDT)
Received: from localhost ([88.98.246.218])
 by smtp.gmail.com with ESMTPSA id 32sm21321484wrg.19.2020.05.19.06.11.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 19 May 2020 06:11:01 -0700 (PDT)
From: luca.boccassi@gmail.com
To: Yunjian Wang <wangyunjian@huawei.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
 Stephen Hemminger <stephen@networkplumber.org>,
 dpdk stable <stable@dpdk.org>
Date: Tue, 19 May 2020 14:03:52 +0100
Message-Id: <20200519130549.112823-97-luca.boccassi@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com>
References: <20200519125804.104349-1-luca.boccassi@gmail.com>
 <20200519130549.112823-1-luca.boccassi@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-stable] patch 'net/tap: fix fd leak on creation failure' has
	been queued to stable release 19.11.3
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/21/20. 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 rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 8e90f78a02bdc2477e5697865c86a8832ac3e32e Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian@huawei.com>
Date: Thu, 16 Apr 2020 11:04:56 +0800
Subject: [PATCH] net/tap: fix fd leak on creation failure

[ upstream commit cbf8909b3aa16c2b1807bd980aad56d8d1e9362e ]

When eth_dev_tap_create() is failed, nlsk_fd and ka_fd won't be closed
thus leading fds leak. Zero is a valid fd. Ultimately leads to a valid
fd was closed by mistake.

Fixes: bf7b7f437b49 ("net/tap: create netdevice during probing")
Fixes: cb7e68da630a ("net/tap: fix cleanup on allocation failure")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/rte_eth_tap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 41ea54888e..fea464c3d2 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1823,6 +1823,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
 	pmd->dev = dev;
 	strlcpy(pmd->name, tap_name, sizeof(pmd->name));
 	pmd->type = type;
+	pmd->ka_fd = -1;
+	pmd->nlsk_fd = -1;
 
 	pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0);
 	if (pmd->ioctl_sock == -1) {
@@ -1853,7 +1855,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
 	dev->intr_handle = &pmd->intr_handle;
 
 	/* Presetup the fds to -1 as being not valid */
-	pmd->ka_fd = -1;
 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
 		process_private->rxq_fds[i] = -1;
 		process_private->txq_fds[i] = -1;
@@ -1993,7 +1994,11 @@ error_remote:
 	tap_flow_implicit_flush(pmd, NULL);
 
 error_exit:
-	if (pmd->ioctl_sock > 0)
+	if (pmd->nlsk_fd != -1)
+		close(pmd->nlsk_fd);
+	if (pmd->ka_fd != -1)
+		close(pmd->ka_fd);
+	if (pmd->ioctl_sock != -1)
 		close(pmd->ioctl_sock);
 	/* mac_addrs must not be freed alone because part of dev_private */
 	dev->data->mac_addrs = NULL;
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:48.421545917 +0100
+++ 0097-net-tap-fix-fd-leak-on-creation-failure.patch	2020-05-19 14:04:44.308650040 +0100
@@ -1,15 +1,16 @@
-From cbf8909b3aa16c2b1807bd980aad56d8d1e9362e Mon Sep 17 00:00:00 2001
+From 8e90f78a02bdc2477e5697865c86a8832ac3e32e Mon Sep 17 00:00:00 2001
 From: Yunjian Wang <wangyunjian@huawei.com>
 Date: Thu, 16 Apr 2020 11:04:56 +0800
 Subject: [PATCH] net/tap: fix fd leak on creation failure
 
+[ upstream commit cbf8909b3aa16c2b1807bd980aad56d8d1e9362e ]
+
 When eth_dev_tap_create() is failed, nlsk_fd and ka_fd won't be closed
 thus leading fds leak. Zero is a valid fd. Ultimately leads to a valid
 fd was closed by mistake.
 
 Fixes: bf7b7f437b49 ("net/tap: create netdevice during probing")
 Fixes: cb7e68da630a ("net/tap: fix cleanup on allocation failure")
-Cc: stable@dpdk.org
 
 Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
 Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>