All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Artem Dinaburg" <artem@trailofbits.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH 6.1.y] net/mlx5e: TC, Fix internal port memory leak
Date: Fri, 25 Sep 2026 17:35:12 +0000	[thread overview]
Message-ID: <20260925173513.273EF1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924173505.87763-1-artem@trailofbits.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mlx5e: double free of int_port in flow post actions backport
--

commit 31e3e836a049949a2f6ef2d83fb49017f4be37e3
Author: Jianbo Liu <jianbol@nvidia.com>

net/mlx5e: TC, Fix internal port memory leak

This commit attempts to fix a memory leak of the internal port object when
flow rules forward packets from an internal port over a tunnel. It moves the
cleanup into free_flow_post_acts() to release references on cloned
post-action attributes.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 05888942ef276..d2f226a09a0c7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
[ ... ]
> @@ -3713,6 +3714,16 @@ free_flow_post_acts(struct mlx5e_tc_flow *flow)
>  				mlx5_modify_header_dealloc(flow->priv->mdev, attr->modify_hdr);
>  		}
>  
> +		if (mlx5e_is_eswitch_flow(flow)) {
> +			esw_attr = attr->esw_attr;
> +			if (esw_attr->int_port)
> +				mlx5e_tc_int_port_put(mlx5e_get_int_port_priv(flow->priv),
> +						      esw_attr->int_port);
> +			if (esw_attr->dest_int_port)
> +				mlx5e_tc_int_port_put(mlx5e_get_int_port_priv(flow->priv),
> +						      esw_attr->dest_int_port);
                                                      ^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Can this cause a double free of the mlx5e_tc_int_port object?

When parsing a multi-table action, mlx5e_clone_flow_attr_for_post_act()
performs a shallow copy of the primary attribute:

mlx5e_clone_flow_attr_for_post_act() {
	...
	memcpy(attr2, attr, attr_sz);
	...
}

This duplicates the dest_int_port and int_port pointers into the cloned
attribute without acquiring new references for them.

During flow deletion, mlx5e_tc_del_fdb_flow() already correctly puts the
primary attribute's dest_int_port, dropping the refcount and freeing the
internal port object:

mlx5e_tc_del_fdb_flow() {
	...
	if (esw_attr->dest_int_port)
		mlx5e_tc_int_port_put(mlx5e_get_int_port_priv(priv),
				      esw_attr->dest_int_port);
	...
}

Since the cloned attributes never took their own references, won't putting
the pointers again here in free_flow_post_acts() result in a use-after-free
and double free of the already-freed mlx5e_tc_int_port object?

> +		}
> +
>  		list_del(&attr->list);
>  		kvfree(attr->parse_attr);
>  		kfree(attr);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924173505.87763-1-artem@trailofbits.com?part=1

  reply	other threads:[~2026-09-25 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 17:35 [PATCH 6.1.y] net/mlx5e: TC, Fix internal port memory leak Artem Dinaburg
2026-09-25 17:35 ` sashiko-bot [this message]
2026-09-25 18:48 ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260925173513.273EF1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=artem@trailofbits.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.