Skip to content

net/mlx5e: Fix crashes in dynamic per-channel stats and HV VHCA agent

Tariq Toukan linux-rdma lkml netdev 4 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 0 repliesApplied 3/3
  2. v33 patches 2 repliesSuperseded
  3. v23 patches 1 replySuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches5 repliesSuperseded

Changes in v4 from the cover letter

- Patch 1/3: also clear priv->stats_agent.{agent,buf} to NULL in mlx5e_hv_vhca_stats_destroy() after freeing them. Making the allocation non-zero in V3 made the kvzalloc() failure path in mlx5e_hv_vhca_stats_create() reachable for the first time; without the NULL assignments a failed create followed by destroy would double-free stale pointers from a previous cycle. (Caught by Simon Horman.)

Patches in v4 All 3 applied

#Subject and filesSizeRepliesApplied
1/3net/mlx5e: Fix HV VHCA stats zero-sized buffer allocationdrivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c+9 -10 repliesApplied
2/3net/mlx5e: Fix HV VHCA stats agent registration racedrivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.h+22 -130 repliesApplied
3/3net/mlx5e: Fix publication race for priv->channel_stats[]drivers/net/ethernet/mellanox/mlx5/core/en.h drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 more+33 -150 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchEran Ben ElishaCosmin RatiuNimrod Oren
1/3R-b
2/3R-b
3/3R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v4 thread

Cover letter [PATCH net V4 0/3] net/mlx5e: Fix crashes in dynamic per-channel stats and HV VHCA agent

Hi,

Since per-channel stats were converted to be allocated and published lazily at first channel open in commit fa691d0c9c08 ("net/mlx5e:
Allocate per-channel stats dynamically at first usage"), priv->channel_stats[] and priv->stats_nch are filled in incrementally during interface bring-up. This opened a window in which the various stats readers - most of them reachable from userspace via netlink/netdev stats queries - can race with mlx5e_open_channel() on another CPU and observe partially initialized state. The HV VHCA stats agent, which is created before the channels are opened, hits related problems of its own.

This series by Feng fixes the resulting crashes.

Regards,
Tariq

V4:
- Patch 1/3: also clear priv->stats_agent.{agent,buf} to NULL in mlx5e_hv_vhca_stats_destroy() after freeing them. Making the allocation non-zero in V3 made the kvzalloc() failure path in mlx5e_hv_vhca_stats_create() reachable for the first time; without the NULL assignments a failed create followed by destroy would double-free stale pointers from a previous cycle. (Caught by Simon Horman.)

V3:
https://lore.kernel.org/all/[email protected]/

V2:
https://lore.kernel.org/all/[email protected]/

Feng Liu (3):
net/mlx5e: Fix HV VHCA stats zero-sized buffer allocation net/mlx5e: Fix HV VHCA stats agent registration race net/mlx5e: Fix publication race for priv->channel_stats[]

 drivers/net/ethernet/mellanox/mlx5/core/en.h  | 12 ++++++
 .../mellanox/mlx5/core/en/hv_vhca_stats.c     | 37 +++++++++++++------
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++---
 .../ethernet/mellanox/mlx5/core/en_stats.c    |  9 +++--
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c |  3 +-
 .../ethernet/mellanox/mlx5/core/lib/hv_vhca.c |  8 +++-
 .../ethernet/mellanox/mlx5/core/lib/hv_vhca.h |  6 ++-
 7 files changed, 62 insertions(+), 27 deletions(-)

base-commit: dbf803bc4a8b0522c9a12560c20905a5952d1cb9

Signature · 1 line
2.44.0