[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250522191651.GL365796@horms.kernel.org>
Date: Thu, 22 May 2025 20:16:51 +0100
From: Simon Horman <horms@...nel.org>
To: Tariq Toukan <tariqt@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
Saeed Mahameed <saeedm@...dia.com>,
Leon Romanovsky <leon@...nel.org>, netdev@...r.kernel.org,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
Moshe Shemesh <moshe@...dia.com>, Mark Bloch <mbloch@...dia.com>,
Gal Pressman <gal@...dia.com>, Jianbo Liu <jianbol@...dia.com>
Subject: Re: [PATCH net 2/2] net/mlx5e: Fix leak of Geneve TLV option object
On Thu, May 22, 2025 at 09:28:06AM +0300, Tariq Toukan wrote:
> From: Jianbo Liu <jianbol@...dia.com>
>
> Previously, a unique tunnel id was added for the matching on TC
> non-zero chains, to support inner header rewrite with goto action.
> Later, it was used to support VF tunnel offload for vxlan, then for
> Geneve and GRE. To support VF tunnel, a temporary mlx5_flow_spec is
> used to parse tunnel options. For Geneve, if there is TLV option, a
> object is created, or refcnt is added if already exists. But the
> temporary mlx5_flow_spec is directly freed after parsing, which causes
> the leak because no information regarding the object is saved in
> flow's mlx5_flow_spec, which is used to free the object when deleting
> the flow.
>
> To fix the leak, call mlx5_geneve_tlv_option_del() before free the
> temporary spec if it has TLV object.
>
> Fixes: 521933cdc4aa ("net/mlx5e: Support Geneve and GRE with VF tunnel offload")
> Signed-off-by: Jianbo Liu <jianbol@...dia.com>
> Reviewed-by: Cosmin Ratiu <cratiu@...dia.com>
> Signed-off-by: Tariq Toukan <tariqt@...dia.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index f1d908f61134..b9c1d7f8f05c 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
> return err;
> }
>
> -static bool mlx5_flow_has_geneve_opt(struct mlx5e_tc_flow *flow)
> +static bool mlx5_flow_has_geneve_opt(struct mlx5_flow_spec *spec)
> {
> - struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;
> void *headers_v = MLX5_ADDR_OF(fte_match_param,
> spec->match_value,
> misc_parameters_3);
> @@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
> }
> complete_all(&flow->del_hw_done);
>
> - if (mlx5_flow_has_geneve_opt(flow))
> + if (mlx5_flow_has_geneve_opt(&attr->parse_attr->spec))
> mlx5_geneve_tlv_option_del(priv->mdev->geneve);
>
> if (flow->decap_route)
Hi,
The lines leading up to the hung below are:
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level);
if (err) {
kvfree(tmp_spec);
NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes");
netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
I am wondering if the same resource leak described in the patch description
can occur if mlx5e_tc_tun_parse() fails after it successfully calls
tunnel->parse_tunnel().
> @@ -2580,6 +2579,8 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
> return err;
> }
> err = mlx5e_tc_set_attr_rx_tun(flow, tmp_spec);
> + if (mlx5_flow_has_geneve_opt(tmp_spec))
> + mlx5_geneve_tlv_option_del(priv->mdev->geneve);
> kvfree(tmp_spec);
> if (err)
> return err;
> --
> 2.31.1
>
>
Powered by blists - more mailing lists