From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4B6F946211 for ; Thu, 13 Feb 2025 11:00:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4191B42ED4; Thu, 13 Feb 2025 11:00:42 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 568E142ED4 for ; Thu, 13 Feb 2025 11:00:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739440839; 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=QTnqSl0BdfgEfkVpSGff9vEIN7CGolnJcuvoCsmBAYA=; b=W1rpaA1g1T01zP9hidwDjJzykk/hyGTcGNNmqPRiWFAgrE835f7H7mLHMUa0LFPemqIIox irq2qXMFGoJtziDqzRrK/Oy0jBbyWBuFagKzlHODpUzRSWMzp30l1asuzzVdL+TGzZ+AFP PIuB7jZJCiiG1yyqFuzb/Qse4TSOPbc= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-XY6zmyt_Oi-h8PZBZLz7bw-1; Thu, 13 Feb 2025 05:00:34 -0500 X-MC-Unique: XY6zmyt_Oi-h8PZBZLz7bw-1 X-Mimecast-MFC-AGG-ID: XY6zmyt_Oi-h8PZBZLz7bw Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2C4CB1800873; Thu, 13 Feb 2025 10:00:33 +0000 (UTC) Received: from rh.Home (unknown [10.45.224.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A5E4E1800365; Thu, 13 Feb 2025 10:00:31 +0000 (UTC) From: Kevin Traynor To: Bing Zhao Cc: Dariusz Sosnowski , dpdk stable Subject: patch 'net/mlx5: fix leak of flow action data list' has been queued to stable release 24.11.2 Date: Thu, 13 Feb 2025 09:57:48 +0000 Message-ID: <20250213095933.362078-21-ktraynor@redhat.com> In-Reply-To: <20250213095933.362078-1-ktraynor@redhat.com> References: <20250213095933.362078-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ekB3zbyoB18JYLKrtBVavgUMjGIxnT5GF62-rgQK6to_1739440833 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Hi, FYI, your patch has been queued to stable release 24.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/17/25. 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 This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/fbc041172e9c2008acd74e8e09f2b9ef0dd4624e Thanks. Kevin --- >From fbc041172e9c2008acd74e8e09f2b9ef0dd4624e Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Tue, 26 Nov 2024 10:34:40 +0200 Subject: [PATCH] net/mlx5: fix leak of flow action data list [ upstream commit d68bcfb6da221ee114835db8c2ab9449d277590f ] In the actions construction for HWS non-template API, the `masks` parameter is always set to NULL and all the actions will be translated in the "construct" stage as non-fixed ones. In the stage of translating actions template, the actions data would be allocated from the pool and managed in a list. The list would be released when destroying the template with the actions. In the NT2HWS implementation, the temporary template was freed directly and the actions will be destroyed with the flow rule deletion. No other rule would use this list anymore. The actions data in the list should be freed when the actions construction is done. Fixes: ff4064d5b1fe ("net/mlx5: support bulk actions in non-template flow") Signed-off-by: Bing Zhao Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_flow_hw.c | 63 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 50dbaa27ab..1de6b889a7 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -967,8 +967,5 @@ __flow_hw_actions_release(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) /** - * Destroy DR actions created by action template. - * - * For DR actions created during table creation's action translate. - * Need to destroy the DR action when destroying the table. + * Release the action data back into the pool without destroy any action. * * @param[in] dev @@ -977,6 +974,6 @@ __flow_hw_actions_release(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) * Pointer to the template HW steering DR actions. */ -static void -__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) +static inline void +__flow_hw_act_data_flush(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) { struct mlx5_priv *priv = dev->data->dev_private; @@ -988,5 +985,21 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_action mlx5_ipool_free(priv->acts_ipool, data->idx); } +} +/* + * Destroy DR actions created by action template. + * + * For DR actions created during table creation's action translate. + * Need to destroy the DR action when destroying the table. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] acts + * Pointer to the template HW steering DR actions. + */ +static void +__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts) +{ + __flow_hw_act_data_flush(dev, acts); __flow_hw_actions_release(dev, acts); } @@ -13493,12 +13506,12 @@ flow_nta_build_template_mask(const struct rte_flow_action actions[], static int flow_hw_translate_flow_actions(struct rte_eth_dev *dev, - const struct rte_flow_attr *attr, - const struct rte_flow_action actions[], - struct rte_flow_hw *flow, - struct mlx5_flow_hw_action_params *ap, - struct mlx5_hw_actions *hw_acts, - uint64_t item_flags, uint64_t action_flags, - bool external, - struct rte_flow_error *error) + const struct rte_flow_attr *attr, + const struct rte_flow_action actions[], + struct rte_flow_hw *flow, + struct mlx5_flow_hw_action_params *ap, + struct mlx5_hw_actions *hw_acts, + uint64_t item_flags, uint64_t action_flags, + bool external, + struct rte_flow_error *error) { int ret = 0; @@ -13543,5 +13556,5 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, if (!table) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION, - actions, "Failed to allocate dummy table"); + actions, "Failed to allocate dummy table"); at = __flow_hw_actions_template_create(dev, &template_attr, actions, masks, true, error); if (!at) { @@ -13557,5 +13570,5 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table->ats[0].action_template = at; ret = __flow_hw_translate_actions_template(dev, &table->cfg, hw_acts, at, - &table->mpctx, true, error); + &table->mpctx, true, error); if (ret) goto end; @@ -13563,19 +13576,21 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, ret = flow_hw_encap_decap_resource_register(dev, table, hw_acts, flow, error); if (ret) - goto clean_up; + goto end; ret = flow_hw_modify_hdr_resource_register(dev, table, hw_acts, flow, error); if (ret) - goto clean_up; + goto end; table->ats[0].acts = *hw_acts; ret = flow_hw_actions_construct(dev, flow, ap, - &table->ats[0], item_flags, table, - actions, hw_acts->rule_acts, 0, error); + &table->ats[0], item_flags, table, + actions, hw_acts->rule_acts, 0, error); if (ret) - goto clean_up; + goto end; goto end; -clean_up: - /* Make sure that there is no garbage in the actions. */ - __flow_hw_action_template_destroy(dev, hw_acts); end: + if (ret) + /* Make sure that there is no garbage in the actions. */ + __flow_hw_action_template_destroy(dev, hw_acts); + else + __flow_hw_act_data_flush(dev, hw_acts); if (table) mlx5_free(table); -- 2.48.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-02-12 17:29:36.830390319 +0000 +++ 0021-net-mlx5-fix-leak-of-flow-action-data-list.patch 2025-02-12 17:29:34.215945124 +0000 @@ -1 +1 @@ -From d68bcfb6da221ee114835db8c2ab9449d277590f Mon Sep 17 00:00:00 2001 +From fbc041172e9c2008acd74e8e09f2b9ef0dd4624e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d68bcfb6da221ee114835db8c2ab9449d277590f ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org