* [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
@ 2026-11-18 2:57 Zhao Li
2026-11-23 9:00 ` Daniel Machon
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zhao Li @ 2026-11-18 2:57 UTC (permalink / raw)
To: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Moshe Shemesh, Shay Drory, Akiva Goldberger, netdev,
linux-rdma, linux-kernel
The peer flow add path hands the duplicated flow over to the origin
flow before it looks up the peer entry for the peer vhca_id. When
that entry is missing, the function returns -ENODEV, and the caller
then deletes the duplicated flow with list_del() on its peer node, a
list head that was never initialised and never linked. list_del() on
such a node writes through the NULL page.
Look the peer entry up before the duplicated flow is created and
handed over, so that a missing entry is reported without leaving a
duplicated flow behind. The entry cannot change in between: the peer
loop in mlx5e_add_fdb_flow() holds the devcom component's read lock,
and peer_flows entries are only stored and erased by the pair and
unpair events, under its write lock.
Found by code review and not reproduced; compile-tested only.
AI assistance was used.
Fixes: 9d608a40c2d4 ("net/mlx5e: TC, track peer flows in a vhca_id xarray")
Signed-off-by: Zhao Li <enderaoelyther@gmail.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 708b7987ea4c..d41969117d30 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -4630,6 +4630,10 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
else
in_mdev = priv->mdev;
+ dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
+ if (!dup_peer_flows)
+ return -ENODEV;
+
flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_PEER);
parse_attr = flow->attr->parse_attr;
peer_flow = __mlx5e_add_fdb_flow(peer_priv, f, flow_flags,
@@ -4643,9 +4647,6 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
peer_flow->peer_orig = flow;
list_add_tail(&peer_flow->peer_flows, &flow->peer_flows);
flow_flag_set(flow, DUP);
- dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
- if (!dup_peer_flows)
- return -ENODEV;
mutex_lock(&esw->offloads.peer_mutex);
list_add_tail(&peer_flow->peer, dup_peer_flows);
mutex_unlock(&esw->offloads.peer_mutex);
base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
2026-11-18 2:57 [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path Zhao Li
@ 2026-11-23 9:00 ` Daniel Machon
2026-11-23 10:10 ` Shay Drori
2026-11-23 12:17 ` Mark Bloch
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Machon @ 2026-11-23 9:00 UTC (permalink / raw)
To: Zhao Li
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Moshe Shemesh, Shay Drory, Akiva Goldberger, netdev,
linux-rdma, linux-kernel
> The peer flow add path hands the duplicated flow over to the origin
> flow before it looks up the peer entry for the peer vhca_id. When
> that entry is missing, the function returns -ENODEV, and the caller
> then deletes the duplicated flow with list_del() on its peer node, a
> list head that was never initialised and never linked. list_del() on
> such a node writes through the NULL page.
>
> Look the peer entry up before the duplicated flow is created and
> handed over, so that a missing entry is reported without leaving a
> duplicated flow behind. The entry cannot change in between: the peer
> loop in mlx5e_add_fdb_flow() holds the devcom component's read lock,
> and peer_flows entries are only stored and erased by the pair and
> unpair events, under its write lock.
>
> Found by code review and not reproduced; compile-tested only.
>
> AI assistance was used.
>
> Fixes: 9d608a40c2d4 ("net/mlx5e: TC, track peer flows in a vhca_id xarray")
> Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
2026-11-18 2:57 [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path Zhao Li
2026-11-23 9:00 ` Daniel Machon
@ 2026-11-23 10:10 ` Shay Drori
2026-11-23 12:17 ` Mark Bloch
2 siblings, 0 replies; 4+ messages in thread
From: Shay Drori @ 2026-11-23 10:10 UTC (permalink / raw)
To: Zhao Li, Saeed Mahameed, Tariq Toukan, Mark Bloch,
Leon Romanovsky
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Moshe Shemesh, Akiva Goldberger, netdev, linux-rdma,
linux-kernel
On 18/11/2026 4:57, Zhao Li wrote:
> External email: Use caution opening links or attachments
>
>
> The peer flow add path hands the duplicated flow over to the origin
> flow before it looks up the peer entry for the peer vhca_id. When
> that entry is missing, the function returns -ENODEV, and the caller
> then deletes the duplicated flow with list_del() on its peer node, a
> list head that was never initialised and never linked. list_del() on
> such a node writes through the NULL page.
>
> Look the peer entry up before the duplicated flow is created and
> handed over, so that a missing entry is reported without leaving a
> duplicated flow behind. The entry cannot change in between: the peer
> loop in mlx5e_add_fdb_flow() holds the devcom component's read lock,
> and peer_flows entries are only stored and erased by the pair and
> unpair events, under its write lock.
>
> Found by code review and not reproduced; compile-tested only.
>
> AI assistance was used.
>
> Fixes: 9d608a40c2d4 ("net/mlx5e: TC, track peer flows in a vhca_id xarray")
> Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
2026-11-18 2:57 [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path Zhao Li
2026-11-23 9:00 ` Daniel Machon
2026-11-23 10:10 ` Shay Drori
@ 2026-11-23 12:17 ` Mark Bloch
2 siblings, 0 replies; 4+ messages in thread
From: Mark Bloch @ 2026-11-23 12:17 UTC (permalink / raw)
To: Zhao Li, Saeed Mahameed, Tariq Toukan, Leon Romanovsky
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Moshe Shemesh, Shay Drory, Akiva Goldberger, netdev,
linux-rdma, linux-kernel
On 18/11/2026 4:57, Zhao Li wrote:
> The peer flow add path hands the duplicated flow over to the origin
> flow before it looks up the peer entry for the peer vhca_id. When
> that entry is missing, the function returns -ENODEV, and the caller
> then deletes the duplicated flow with list_del() on its peer node, a
> list head that was never initialised and never linked. list_del() on
> such a node writes through the NULL page.
>
> Look the peer entry up before the duplicated flow is created and
> handed over, so that a missing entry is reported without leaving a
> duplicated flow behind. The entry cannot change in between: the peer
> loop in mlx5e_add_fdb_flow() holds the devcom component's read lock,
> and peer_flows entries are only stored and erased by the pair and
> unpair events, under its write lock.
>
> Found by code review and not reproduced; compile-tested only.
>
> AI assistance was used.
>
> Fixes: 9d608a40c2d4 ("net/mlx5e: TC, track peer flows in a vhca_id xarray")
> Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Acked-by: Mark Bloch <mbloch@nvidia.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 708b7987ea4c..d41969117d30 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -4630,6 +4630,10 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
> else
> in_mdev = priv->mdev;
>
> + dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
> + if (!dup_peer_flows)
> + return -ENODEV;
> +
> flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_PEER);
> parse_attr = flow->attr->parse_attr;
> peer_flow = __mlx5e_add_fdb_flow(peer_priv, f, flow_flags,
> @@ -4643,9 +4647,6 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
> peer_flow->peer_orig = flow;
> list_add_tail(&peer_flow->peer_flows, &flow->peer_flows);
> flow_flag_set(flow, DUP);
> - dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
> - if (!dup_peer_flows)
> - return -ENODEV;
> mutex_lock(&esw->offloads.peer_mutex);
> list_add_tail(&peer_flow->peer, dup_peer_flows);
> mutex_unlock(&esw->offloads.peer_mutex);
>
> base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 12:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 2:57 [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path Zhao Li
2026-11-23 9:00 ` Daniel Machon
2026-11-23 10:10 ` Shay Drori
2026-11-23 12:17 ` Mark Bloch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox