* [PATCH net v2] net/mlx5e: Skip hairpin entries not ready in debugfs dump
@ 2026-11-20 2:15 Changyul Lee
2026-11-20 2:20 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Changyul Lee @ 2026-11-20 2:15 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Gal Pressman, netdev, linux-rdma, linux-kernel, Changyul Lee
mlx5e_hairpin_flow_add() adds a new hairpin entry to hairpin_tbl and
drops hairpin_tbl_lock before creating the hairpin, and sets hpe->hp
only after mlx5e_hairpin_create() returns. Other users of the entry wait
for res_ready, but debugfs_hairpin_table_dump_show() does not, so
reading hairpin_table_dump in that window dereferences a NULL hpe->hp,
or an ERR_PTR when the creation fails.
Skip entries whose res_ready is not completed or whose hp is an error.
Fixes: 8a0594c09610 ("net/mlx5e: Add more information to hairpin table dump")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
Changes in v2:
- Point the Fixes: tag to 8a0594c09610, which added the hpe->hp
dereference to the dump (Tariq)
- Add Reviewed-by from Tariq
v1: https://lore.kernel.org/all/20261119012707.555494-1-lcy8047@gmail.com/
Found with a static analysis tool we are developing.
Compile-tested only, with x86_64_defconfig plus MLX5_CORE_EN,
MLX5_ESWITCH, MLX5_CLS_ACT and W=1.
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1d35c97aea0b..c6623f13261b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1067,12 +1067,15 @@ static int debugfs_hairpin_table_dump_show(struct seq_file *file, void *priv)
u32 bkt;
mutex_lock(&tc->hairpin_tbl_lock);
- hash_for_each(tc->hairpin_tbl, bkt, hpe, hairpin_hlist)
+ hash_for_each(tc->hairpin_tbl, bkt, hpe, hairpin_hlist) {
+ if (!completion_done(&hpe->res_ready) || IS_ERR(hpe->hp))
+ continue;
seq_printf(file,
"Hairpin peer_vhca_id %u prio %u refcnt %u num_channels %u num_packets %lu\n",
hpe->peer_vhca_id, hpe->prio,
refcount_read(&hpe->refcnt), hpe->hp->num_channels,
BIT(hpe->hp->log_num_packets));
+ }
mutex_unlock(&tc->hairpin_tbl_lock);
return 0;
base-commit: 342e62fd34c2674e82bffc89cb5c7091924986d9
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] net/mlx5e: Skip hairpin entries not ready in debugfs dump
2026-11-20 2:15 [PATCH net v2] net/mlx5e: Skip hairpin entries not ready in debugfs dump Changyul Lee
@ 2026-11-20 2:20 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-20 2:20 UTC (permalink / raw)
To: Changyul Lee; +Cc: linux-rdma
> mlx5e_hairpin_flow_add() adds a new hairpin entry to hairpin_tbl and
> drops hairpin_tbl_lock before creating the hairpin, and sets hpe->hp
> only after mlx5e_hairpin_create() returns. Other users of the entry wait
> for res_ready, but debugfs_hairpin_table_dump_show() does not, so
> reading hairpin_table_dump in that window dereferences a NULL hpe->hp,
> or an ERR_PTR when the creation fails.
>
> Skip entries whose res_ready is not completed or whose hp is an error.
>
> Fixes: 8a0594c09610 ("net/mlx5e: Add more information to hairpin table dump")
> Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120021557.1630138-1-lcy8047@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 2:15 [PATCH net v2] net/mlx5e: Skip hairpin entries not ready in debugfs dump Changyul Lee
2026-11-20 2:20 ` sashiko-bot
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.