From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D61BC35C18A; Wed, 3 Dec 2025 16:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779805; cv=none; b=WjMVcRYOMkfJO01+FFOwh8IcjI0JoeRKZBG7F8ZaZZKPxDuRilChxjzatPymBNwX0kqyWGIUGOG7UECBkFXRbwJpvtJfh1qsauh94/rHPPT5BHiIzBLsWU6M5kUwWOQ2PX5NCVe6UM2nzDGbGp2LLlip13xDqS4j/GS+yO1a0tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764779805; c=relaxed/simple; bh=7dqg+gK80b2uZ4YANs0J4zAbuGFIyteM84y4b2K2aCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VACE76XoLX/riwit5RFKKk4JqKMm6B6mYp7wikrUZYX3VPnWycpy6faHXWqoeg2OJJFZOh0CujDU/dOS3jUBYwFQnNaINr6OfZMXCAj3Nq1PWvbok9xmEEBXGC22g+fktyxXHg+mC7pzN+7L/u1pOw+GE+b3UWp0zrXW3G8xcxY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pfshkn35; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pfshkn35" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44664C4CEF5; Wed, 3 Dec 2025 16:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764779805; bh=7dqg+gK80b2uZ4YANs0J4zAbuGFIyteM84y4b2K2aCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pfshkn35Opr5tsvWLW3Ru2DlNjnNNgHPx6fe1uv3txrEMueEuvDREDYy/sQHLJ4n4 RyLgvSxZWOoxdyzM2+76xHujgm5tgFB7Z+xegtBeE4lzyy5l01M0KfOu8/T74RFg+m SNCAdWwmGpiqa5Xn3nObx3bdHmQsvv6xo8oUoN6U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gal Pressman , Nimrod Oren , Tariq Toukan , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 367/568] net/mlx5e: Fix wraparound in rate limiting for values above 255 Gbps Date: Wed, 3 Dec 2025 16:26:09 +0100 Message-ID: <20251203152454.140294239@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152440.645416925@linuxfoundation.org> References: <20251203152440.645416925@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gal Pressman [ Upstream commit 43b27d1bd88a4bce34ec2437d103acfae9655f9e ] Add validation to reject rates exceeding 255 Gbps that would overflow the 8 bits max bandwidth field. Fixes: d8880795dabf ("net/mlx5e: Implement DCBNL IEEE max rate") Signed-off-by: Gal Pressman Reviewed-by: Nimrod Oren Signed-off-by: Tariq Toukan Link: https://patch.msgid.link/1762681073-1084058-5-git-send-email-tariqt@nvidia.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c index cfbf39f0f8727..2d20e2ff29677 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c @@ -588,11 +588,13 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev, u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; __u64 upper_limit_mbps; + __u64 upper_limit_gbps; int i; memset(max_bw_value, 0, sizeof(max_bw_value)); memset(max_bw_unit, 0, sizeof(max_bw_unit)); upper_limit_mbps = 255 * MLX5E_100MB; + upper_limit_gbps = 255 * MLX5E_1GB; for (i = 0; i <= mlx5_max_tc(mdev); i++) { if (!maxrate->tc_maxrate[i]) { @@ -604,10 +606,16 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev, MLX5E_100MB); max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1; max_bw_unit[i] = MLX5_100_MBPS_UNIT; - } else { + } else if (max_bw_value[i] <= upper_limit_gbps) { max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], MLX5E_1GB); max_bw_unit[i] = MLX5_GBPS_UNIT; + } else { + netdev_err(netdev, + "tc_%d maxrate %llu Kbps exceeds limit %llu\n", + i, maxrate->tc_maxrate[i], + upper_limit_gbps); + return -EINVAL; } } -- 2.51.0