From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379420; b=vWrgYD+txOgdlBOwY1tGMAezuU80z7pk5zhRh0iOh9uHyXSRNrtRZZg92s2gkOnZZ4TW SiWDSfdlQuI2EcsbDmFLvfNlgNm8CuVKVne1hdjCYbOZrWYNgeNCCRIA6Vb0xM3GO/U+T o3OXUKZlKMRtR/wDRUDS9xQMf/USPHPQnqccvkEgqA2wk7tavCTJKKidnBmNrT7gpnw9Q cYORo9Ib8wR96QUG+kj53SuJ5FXenCZGtVudU82220jVjwjMVHXHWOIR+1dWAPKhJYgj9 R2C9raxhWzaRqO7Nieap6WzUAaB+ovJTDwOxAwSfr4DGFZAZhULmvY9NP1WQhT459ww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379420; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=LlrzljX55pi27FT+JlBWmuUJj++ZAwtXO0vVkG9Ll+Q=; b=az+QQ814xij0iUFeX78XW6HWabDdf4JybCNtbk9LUZVBxotb9DD4PAKxxvEnwRZcFJMI W2iwezN/D/OkDRbFYIs65sgq0x3VAe+D8QKRByasbjH4aprwngTxONEEDQi96SZvB3Qwe 1CqXdIScyjEISV4klcYMi7HzmCAjWzhjIcXRbAt++D8wAN3oF8NrXbofcd5eUmW+6mHzA lrSxZJ7ZOHvQqUGyGAdsg3tZUPhiWhZnZNPfO6ncSX4ZiGHY0xWXgfQzSvHvM5jZAQcvX a7ALL/zbNGch7x4hK3dHdVBHQaiLa5ONwKeVDiUhdZ18FPhN+Ptv9WRT0TVg+ReSbyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=I2badP6d; arc=none smtp.remote-ip=100.103.45.18 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 B4117606A322; Fri, 4 Dec 2026 10:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=I2badP6d Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DB3F1F000CE; Fri, 4 Dec 2026 10:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379420; bh=LlrzljX55pi27FT+JlBWmuUJj++ZAwtXO0vVkG9Ll+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I2badP6diVxQnG22QK7iaAYvkMFCebLRHdBHdNMMpeMjZkjj4p82yjcUtsio33/tW tV2HruqOHG+clKTzUsIce7NiCpiLSQjSRXO+nCcIQfTBa+cUgbIch687MWsgY39WK8 BRoO4Ff3oSdMTxr1M7sqgCMLEnjsBSaTYrWuh0+s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Tariq Toukan , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats Date: Fri, 4 Dec 2026 19:00:52 +0900 Message-ID: <20261204100604.276353707@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao [ Upstream commit 9a24799e219b1699bb1c144248c8c500b9504db5 ] I am seeing the following mlx5e crash in the Meta fleet: pc : mlx5e_get_queue_stats_rx+0x4c/0xc8 Call trace: mlx5e_get_queue_stats_rx+0x4c/0xc8 (P) netdev_stat_queue_sum+0x78/0x480 netdev_nl_qstats_get_dump_one+0xf0/0x268 netdev_nl_qstats_get_dumpit+0x7c/0x1f8 When dumping device-wide qstats, the core calls the per-queue callbacks for every queue below real_num_{rx,tx}_queues, regardless of whether the netdev is up. Some of those queues have no stats behind them: - RX stats live in priv->channel_stats[], which only has entries for channels that have been opened (stats_nch). real_num_rx_queues can be larger, for example after the channel count is raised while the netdev is down, or after opening the channels failed part way. - TX stats are looked up in priv->txq2sq_stats[], which is NULL for SQs that were never activated and for HTB queues while the channels are closed. In both cases the callback dereferences a NULL pointer. The dump needs no privileges, so any user can trigger it. Return early for RX queues at or above stats_nch and for TX queues without SQ stats. Fixes: 7b66ae536a78 ("net/mlx5e: Add per queue netdev-genl stats") Cc: stable@vger.kernel.org Signed-off-by: Breno Leitao Reviewed-by: Tariq Toukan Link: https://patch.msgid.link/20261104-mlx5e-qstats-null-v1-1-a6a003245cec@debian.org Signed-off-by: Jakub Kicinski [ sashal: Adjusted the patch context for the existing ASSERT_RTNL() in the RX callback and the TX callback ending after packet and byte counters. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 1f46eae73319d..d6152dac2432e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5291,7 +5291,7 @@ static void mlx5e_get_queue_stats_rx(struct net_device *dev, int i, struct mlx5e_rq_stats *rq_stats; ASSERT_RTNL(); - if (mlx5e_is_uplink_rep(priv) || !mlx5e_stats_nch_read(priv)) + if (mlx5e_is_uplink_rep(priv) || i >= mlx5e_stats_nch_read(priv)) return; channel_stats = priv->channel_stats[i]; @@ -5319,6 +5319,9 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i, * inactive sqs. */ sq_stats = priv->txq2sq_stats[i]; + if (!sq_stats) + return; + stats->packets = sq_stats->packets; stats->bytes = sq_stats->bytes; } -- 2.53.0