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 57039A04A3 for ; Fri, 5 Jun 2020 20:27:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 331011D530; Fri, 5 Jun 2020 20:27:02 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id CF1E11D525 for ; Fri, 5 Jun 2020 20:27:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591381620; 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=M7prQIaX89S3XUV9UxIasmd4eGu3K792swsTBdA8jN8=; b=TCqdcIMgqFgk55Ub4NjPRdciIkb+JuKDRYSuIOU1OJzghtp98dR4zhw9fshScoQMKR3tCH EJUwfH3Njt9HA3NwX65UHoM7QfewMsLLRLf1GxqzRUvnSV2zvp2I0kNoT1ema+zO9D6d7e GXkkco8Q9efRt16VKi5v1svSkLM0Kz0= 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-509-e1mPYUR9OK2z60B10lVC_A-1; Fri, 05 Jun 2020 14:26:56 -0400 X-MC-Unique: e1mPYUR9OK2z60B10lVC_A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55FFF8010D9; Fri, 5 Jun 2020 18:26:50 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 499076199D; Fri, 5 Jun 2020 18:26:49 +0000 (UTC) From: Kevin Traynor To: Yunjian Wang Cc: Gaetan Rivet , Ali Alnubani , dpdk stable Date: Fri, 5 Jun 2020 19:24:29 +0100 Message-Id: <20200605182525.22483-32-ktraynor@redhat.com> In-Reply-To: <20200605182525.22483-1-ktraynor@redhat.com> References: <20200605182525.22483-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/failsafe: fix fd leak' has been queued to LTS release 18.11.9 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.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/10/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. 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/6268dc292c836f2b1b1576e35eef8ecf7edd9a80 Thanks. Kevin. --- >From 6268dc292c836f2b1b1576e35eef8ecf7edd9a80 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Mon, 27 Apr 2020 18:44:19 +0800 Subject: [PATCH] net/failsafe: fix fd leak [ upstream commit b9663f60359296bcb6f0be8a3d6a2a838c77ee30 ] Zero is a valid fd. The fd won't be closed thus leading fd leak, when it is zero. Also the service proxy is initialized at 0. This is assuming that all of its fields are invalid at 0. The issue is that a file descriptor at 0 is a valid one. The value -1 is used as sentinel during cleanup. Initialize the RX proxy file descriptor to -1. Fixes: f234e5bd996d ("net/failsafe: register slaves Rx interrupts") Fixes: 9e0360aebf23 ("net/failsafe: register as Rx interrupt mode") Signed-off-by: Yunjian Wang Signed-off-by: Gaetan Rivet Tested-by: Ali Alnubani --- drivers/net/failsafe/failsafe.c | 1 + drivers/net/failsafe/failsafe_intr.c | 2 +- drivers/net/failsafe/failsafe_ops.c | 2 +- drivers/net/failsafe/failsafe_private.h | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 06e859e9fd..0180954123 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -183,4 +183,5 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) priv = PRIV(dev); priv->dev = dev; + priv->rxp = FS_RX_PROXY_INIT; dev->dev_ops = &failsafe_ops; dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0]; diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c index 1c2cb71c41..de229b2c2f 100644 --- a/drivers/net/failsafe/failsafe_intr.c +++ b/drivers/net/failsafe/failsafe_intr.c @@ -395,5 +395,5 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv) priv->rxp.evec = NULL; } - if (priv->rxp.efd > 0) { + if (priv->rxp.efd >= 0) { close(priv->rxp.efd); priv->rxp.efd = -1; diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 595278bbf7..a3c30c25a9 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -380,5 +380,5 @@ fs_rx_queue_release(void *queue) dev = rxq->priv->dev; fs_lock(dev, 0); - if (rxq->event_fd > 0) + if (rxq->event_fd >= 0) close(rxq->event_fd); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 3264bff2f8..cfe29c3f33 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -59,4 +59,12 @@ struct rx_proxy { }; +#define FS_RX_PROXY_INIT (struct rx_proxy){ \ + .efd = -1, \ + .evec = NULL, \ + .sid = 0, \ + .scid = 0, \ + .sstate = SS_NO_SERVICE, \ +} + struct rxq { struct fs_priv *priv; -- 2.21.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-06-05 19:20:52.615257891 +0100 +++ 0032-net-failsafe-fix-fd-leak.patch 2020-06-05 19:20:50.761041926 +0100 @@ -1 +1 @@ -From b9663f60359296bcb6f0be8a3d6a2a838c77ee30 Mon Sep 17 00:00:00 2001 +From 6268dc292c836f2b1b1576e35eef8ecf7edd9a80 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b9663f60359296bcb6f0be8a3d6a2a838c77ee30 ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -31 +32 @@ -index 8af31d71b3..72362f35de 100644 +index 06e859e9fd..0180954123 100644 @@ -34 +35 @@ -@@ -191,4 +191,5 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) +@@ -183,4 +183,5 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) @@ -36 +37 @@ - priv->data = dev->data; + priv->dev = dev; @@ -41 +42 @@ -index d8728fe7e3..602c04033c 100644 +index 1c2cb71c41..de229b2c2f 100644 @@ -44 +45 @@ -@@ -394,5 +394,5 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv) +@@ -395,5 +395,5 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv) @@ -52 +53 @@ -index 50f2aca4e7..e1d08e46c8 100644 +index 595278bbf7..a3c30c25a9 100644 @@ -55,2 +56,2 @@ -@@ -381,5 +381,5 @@ fs_rx_queue_release(void *queue) - dev = &rte_eth_devices[rxq->priv->data->port_id]; +@@ -380,5 +380,5 @@ fs_rx_queue_release(void *queue) + dev = rxq->priv->dev; @@ -63 +64 @@ -index 8e9706aef0..651578a128 100644 +index 3264bff2f8..cfe29c3f33 100644