* [PATCH net] net/mlx5e: Fix shared buffer size underflow
@ 2026-12-02 13:13 Tariq Toukan
2026-12-03 13:16 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-12-02 13:13 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni, Willem de Bruijn
Cc: Alex Lazar, Elliot Edmunds, Gal Pressman, Leon Romanovsky,
linux-rdma, Maher Sanalla, Mark Bloch, Moshe Shemesh,
Saeed Mahameed, Tariq Toukan
From: Elliot Edmunds <eedmunds@nvidia.com>
port_update_shared_buffer() computes shared_buffer_size as a u32.
When the new headroom exceeds the current headroom plus both pools,
it wraps, passes the "< 4" check, and the wrapped split is written
to SBPR. mlnx_qos exits 0 with the pools reading 32709/32748 cells.
Refuse such a request before any register write.
Fixes: a440030d8946 ("net/mlx5e: Update shared buffer along with device buffer changes")
Signed-off-by: Elliot Edmunds <eedmunds@nvidia.com>
Reviewed-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Alex Lazar <alazar@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
index 4720523813b9..622ea8d9b12a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
@@ -264,7 +264,7 @@ static int port_update_shared_buffer(struct mlx5_core_dev *mdev,
lossless_ipool.size;
shared_buffer_size = total_buffer_size - new_headroom_size;
- if (shared_buffer_size < 4) {
+ if (new_headroom_size > total_buffer_size || shared_buffer_size < 4) {
pr_err("Requested port buffer is too large, not enough space left for shared buffer\n");
return -EINVAL;
}
base-commit: b6c8f45ed340f00bf2004d407cf7316fe3e24c48
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/mlx5e: Fix shared buffer size underflow
2026-12-02 13:13 [PATCH net] net/mlx5e: Fix shared buffer size underflow Tariq Toukan
@ 2026-12-03 13:16 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 13:16 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, willemb,
alazar, eedmunds, gal, leon, linux-rdma, msanalla, mbloch, moshe,
saeedm
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message says the request is refused "before any
register write".
--
net/mlx5e: Fix shared buffer size underflow
This commit adds a check to port_update_shared_buffer() that rejects a
request when the new headroom is larger than the current headroom plus
the lossy egress and lossless ingress pools. Without the check, the u32
shared_buffer_size wraps and the wrapped split is written to SBPR.
> Refuse such a request before any register write.
Does this hold when one DCB_ATTR_DCB_BUFFER request changes both the
prio-to-buffer mapping and the buffer sizes? More detail is inline
below.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
> index 4720523813b97..622ea8d9b12a5 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
> @@ -264,7 +264,7 @@ static int port_update_shared_buffer(struct mlx5_core_dev *mdev,
> lossless_ipool.size;
> shared_buffer_size = total_buffer_size - new_headroom_size;
>
> - if (shared_buffer_size < 4) {
> + if (new_headroom_size > total_buffer_size || shared_buffer_size < 4) {
[Severity: Medium]
Can a request rejected here leave SBCM already reprogrammed?
mlx5e_dcbnl_setbuffer() sets both MLX5E_PORT_BUFFER_PRIO2BUFFER and
MLX5E_PORT_BUFFER_SIZE in changed when both arrays differ from the
current config. It then calls mlx5e_port_manual_buffer_config() once.
In that function the PRIO2BUFFER block runs first:
mlx5e_port_manual_buffer_config() {
...
if (change & MLX5E_PORT_BUFFER_PRIO2BUFFER) {
...
err = update_buffer_lossy(priv->mdev, max_mtu, curr_pfc_en, prio2buffer, xoff,
port_buff_cell_sz, &port_buffer, &update_buffer);
...
}
If the remap flips the lossy bit on any buffer, update_buffer_lossy()
writes the pool config right away:
update_buffer_lossy() {
...
if (changed) {
...
err = port_update_pool_cfg(mdev, port_buffer);
...
}
When sbcam_reg is supported, port_update_pool_cfg() writes SBCM for all
MLX5E_MAX_NETWORK_BUFFER buffers through mlx5e_port_set_sbcm(). It uses
the new lossy bits and the old sizes.
Next, the SIZE block passes the coarser spare_buffer_size check. Then
port_set_buffer()->port_update_shared_buffer() reaches the new condition
and returns -EINVAL. PBMC is never written, and
mlx5e_port_manual_buffer_config() returns before it gets here:
if (update_prio2buffer)
err = mlx5e_port_set_priority2buffer(priv->mdev, prio2buffer);
The device is then left with SBCM pool bindings for the new
lossy/lossless layout. PBMC still has the old lossy bits and sizes, and
PPTB still has the old prio2buffer mapping. Nothing rolls SBCM back,
and user space only sees -EINVAL.
This can be reached with mlnx_qos using both --prio2buffer and
--buffer_size, as long as the remap flips a lossy bit and the requested
headroom passes the PBMC spare check but is larger than the current
headroom plus both pools.
The missing rollback is older than this patch, since the existing
spare_buffer_size reject behaves the same way. However, the commit
message says the request is refused before any register write.
Should the shared buffer admission check move ahead of
update_buffer_lossy() in mlx5e_port_manual_buffer_config()? If not,
could the commit message be reworded so it doesn't make that claim?
> pr_err("Requested port buffer is too large, not enough space left for shared buffer\n");
> return -EINVAL;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202131331.3445566-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:13 [PATCH net] net/mlx5e: Fix shared buffer size underflow Tariq Toukan
2026-12-03 13:16 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox