Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5e: psp: Fix stack info leak in PSP device stats
@ 2026-11-26 21:11 Tariq Toukan
  2026-11-26 21:13 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-11-26 21:11 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni, Willem de Bruijn
  Cc: Aleksandr Loktionov, Boris Pismenny, Cosmin Ratiu, Daniel Zahka,
	Dragos Tatulea, Gal Pressman, Leon Romanovsky, linux-rdma,
	Mark Bloch, Raed Salem, Rahul Rameshbabu, Saeed Mahameed,
	Tariq Toukan

mlx5e_psp_get_stats() reads the PSP flow counters into an uninitialized
on-stack struct. mlx5e_accel_psp_fs_get_stats_fill() ignores the
mlx5_fc_query() return value, and a failed query, e.g. -ENOLINK when the
device is in internal error state, leaves the counter fields unset. The
uninitialized stack values are then reported to user space through the
PSP get-stats netlink command.

Zero-initialize the struct, so the counters of a failed query read 0.

Fixes: b1346219e535 ("net/mlx5e: Add PSP stats support for Rx/Tx flows")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
index 73b232379263..4aacb4173b1b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
@@ -995,7 +995,7 @@ static void
 mlx5e_psp_get_stats(struct psp_dev *psd, struct psp_dev_stats *stats)
 {
 	struct mlx5e_priv *priv = netdev_priv(psd->main_netdev);
-	struct mlx5e_psp_stats nstats;
+	struct mlx5e_psp_stats nstats = {};
 
 	mlx5e_accel_psp_fs_get_stats_fill(priv, &nstats);
 	stats->rx_packets = nstats.psp_rx_pkts;

base-commit: e1055cbfd6eb578417f3ce983cf44462e8465267
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26 21:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 21:11 [PATCH net] net/mlx5e: psp: Fix stack info leak in PSP device stats Tariq Toukan
2026-11-26 21:13 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox