Article View: linux.kernel.netdev
Article #26399Re: [PATCH net] net/mlx5e: Fix shared buffer size underflow
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 13:16
Date: Thu, 03 Dec 2026 13:16
105 lines
12063 bytes
12063 bytes
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
Technical Details
Message-ID:
<179630377858.3146.2768042714544546840@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376626-linux-kernel-netdev=dewy.ruReferences:
<20261202131331.3445566-1-tariqt@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376626-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/mlx5e: Fix shared buffer size underflow Date: Thu, 03 Dec 2026 13:16:18 +0000 Organization: Usenet Network Message-ID: <179630377858.3146.2768042714544546840@kernel.org> References: <20261202131331.3445566-1-tariqt@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2500143"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3iJKw1c/zSfH/VxXy5p8jQn67U4= sha256:Ck/G1ZN3r5rMhEpbGGQW4EgmL4NxM5razCak2bzWxDg= sha1:sbH2KAL+cL8JZIZHgTqR8QX9CxM= sha256:6w9zN8iI+kEmUjzfA+OOK9Bk3AfdTPOmNgMs5ZKZg0M= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 98BE611795B; Thu, 3 Dec 2026 16:16:49 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H-LOQgnYevP3; Thu, 3 Dec 2026 16:16:42 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376626-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 2C776117952; Thu, 3 Dec 2026 16:16:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 24709238A8; Thu, 3 Dec 2026 13:16:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796303787; b=xbJ3ZBoMxqeB/mvl9eLIdyJo2MIZ0r9DMMUdKjBkzT3Fpp0rPzzRcQsxXW2Bmdfm8S0X CasH1/x0aEvuYy0aRVqvZy5OwJg6n4BvBFgqPWsLq19zJPqaIXvDhdAxpLl1n0Ng+O94Y RVHcKzSK9Z2rtL46k3UryuSDknbfbiY3R/ouxFE2w2axnUtCkZXCZavtp0rl/IWJhlUbK Y4ur3XDTUiO9r4cieFdOYR0yIDphoXOxqGphSjGJqzOgXtNxVUSM5ZgCavwhFL87TiKgg hBVP99X05WDsqjEexJ1BrVv4SQxwKq0ySQVu0Z4pksltJ2z3Yi/78TlFYkwhrsN2SXA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303787; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=zdYVyHKJmls37aGvHovEi3YjicQCnZ6+BzfR9vF/s5w=; b=H0GvNfNFUWjVJCrCYvwhUgX7pc2gR1SajCyWQOIH6zja+ZJGu9/oxOQOXiTwtVhYcyfW FNS7HbX4/uwDQk1gskLy2JHkLZiZuZqO+c946KQksmNtLm8ZrV0hq4hrBAPexIKfhrZNC LjDsW2R9UHaZQ70RhIUFIGMbyTZGlWLbmf15A2DsBaEpNRcHA52DIRF6qQWi2CwuI6iNH itPi/BF1vUqxL/ije3LwfB3Dx1VP93s13j/dRRHmbWktL+elBonzdSnLE8ZXCRF6jzm1u ezYccfJCnDqJ3qDPy1k952yMtgu6PMpK/PqzOboSWubtk0aPXeaPSqPQQi4E/2MQLAg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aLPBajyH; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC326606A682; Thu, 3 Dec 2026 13:16:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aLPBajyH X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303780; b=0EQKXjJL2pOyOLXTixmfgJHNTvEH76LewYQ9MocTxRK4HX7bYJeUIim+WT+RrEUZQL5H kSszSdFE5zZgZo8OM1QzwzLgNT3/E0ZZRuaXjbdnA3cwXOjEKaRezLKHeabmyQcJN1nUc 5rH6rcd+Fpu03vHUVIlEXO7x3UwUXg6zRhGALAiJFD5jJptcB5b4wIPyVwsl9zvHGL47+ G7IFr8av55qWgDQKR6dgGeSEAhNmL7IQBUCLPiMOl2vbpxXTwlUp8/JrFqxm0ze+SSXQ0 +bC+ZWUzWQ5gvAtGB+BHAj68k4CYRgsGkKSIFmqDAF/zlpL0BbNLEj749lb6amjMmAA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303780; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=zdYVyHKJmls37aGvHovEi3YjicQCnZ6+BzfR9vF/s5w=; b=OXz5iVUyue+WCI3VyaeWza+ZQY4ToJoT0TKhBwEi5bSK/y+ljtE4rCDA3JYkckE1Wn6d XYkI5CejlTxJMHZ5MiQHYEiHJtDeUIOreKiKx0QhFKkZ2/ESXmy/KQuXYalBzz2/kkUJM SVaPzqLUxT0cNMnquWC38wLDX8U9LGf7Bg45EUMY1E/ElDq6MN6j+RI33wgzxpAIyMO4I 4M+IQn55ruNZHICaWtUPkxoGtjB9OBondRABZo9TN48m2sBwV2RCpkQ7TVMhHDHdq1c5i 0JmEeA8sXkLyCYJXSz0XmERFJrY+6gaNsZpCoKs9maw4+CQdCmNbpDErDPbjOdTPv6A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aLPBajyH; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 587C3606A322; Thu, 3 Dec 2026 13:16:20 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10F3C1F000C1; Thu, 3 Dec 2026 13:16:19 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796303780; bh=zdYVyHKJmls37aGvHovEi3YjicQCnZ6+BzfR9vF/s5w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=aLPBajyHNeXoyrDAJ9XQFiCfS7u1jqeRTAQGwT450RiuuYMe4HobK+6Z+JZ23QdUP +nrlIM/glhWK8A3I+d1WcjyREMKZs2wKEXnRz33kML+U2U+7r1konaa7Fpv/Rhn8uH ZQO7daIj5txScc6Z6qTF6BNKQdi2j7aGpLuOqiXcGfuGVgirHZ4wjHtKL7qCV9iCZT 8T6QtH+YSJpO8aP/9KHHMTzS9m1yQnqkPJBFILP/Fb64OwCpfh/q7YFS0Oe3dHniY4 yLIc0VKRbHpJoRufhi/nzfVjUx4XXnAVhQaPc1NSo3PEF/acwXvi1BQCtPT96EQME0 +AKHj5Hlo7Fgg== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com, alazar@nvidia.com, eedmunds@nvidia.com, gal@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org, msanalla@nvidia.com, mbloch@nvidia.com, moshe@nvidia.com, saeedm@nvidia.com X-In-Reply-To: <20261202131331.3445566-1-tariqt@nvidia.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list