From patchwork Fri Sep 18 14:26:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 2308106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hmr0C2q88z1xwp for ; Sat, 19 Sep 2026 10:26:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x7iuk-0004tM-2b; Sat, 19 Sep 2026 00:26:46 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x7iui-0004rD-2g for kernel-team@lists.ubuntu.com; Sat, 19 Sep 2026 00:26:44 +0000 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id DD58C3F1E0 for ; Sat, 19 Sep 2026 00:26:43 +0000 (UTC) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49d156c917cso13140675e9.1 for ; Fri, 18 Sep 2026 17:26:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789777603; x=1790382403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WqdhvxIDoHBiTwnV4NsNyV0hcMb6LWHylHeF5FC+lko=; b=UPBVGo1rKFy5H5ZOG7mbatGe00nx0svR7blBlwQaTNVVhzR/opVxYDMrFLeD3xSDfh H0bvok7NTD8dZ++perGrg3Z5agYyMME7CXCGxHrrsw+nvNZ4nrVSTDYV5EUFGLshggO1 Wh/vNvffGbCh18Q1l8dnTQA+LMELA8fGf7eUh2fFWnLhUN6kuWF5yzBEkr1CJU4Hlw7i iKNmZqmr1RGWiCzWx0yC5CmPBOyPaL0pTZ5FPb8B3Hi/nzdeMDDw6g+CfkCjvX3niBXF H6nyMjjErz5wXQgYv/i0TClDNXNkYiznxz3QteD/sQms0gRj6g9CoMob6DGOiPiBdz10 Zv4w== X-Gm-Message-State: AFuF++lnpyyrZ80GkJ//9oBKBEeviiCY9c13EE0Lj4dMBwOtFSuK+gff PkzatJ4OevW9s6bLeqC431NT0HNLtj97mdCAslMDBwCyODmadE/Cfh24yebSe7m1DiyFSOL45sE afC7mVpgcW4/75LsFKa++hGb3mO78ugIByEjyIKvQE1KhUX+q+z9p76fqOhiFel6SfQcVH7APuY +Y6WKblrYYSyBx0g== X-Gm-Gg: AYBFou20PK8nsLB+231DtJFsZeXf8nMvmqRBsrFfDafToB8kum9WgP5F/l2Zs4OZuB/ 2rcFosT1/J2SPWeGxJfbF4PsA52qPaNOdc+7GQlvdPM9BM29E9og8LUlmjSzyZR7Cl4UjiAVeGn Bz6NCq5pvV8y01VEX6d1UqeSLf7cJ21CN+PukGA2u5B/HLTPxbYUszTtlZKZNhnTL0zkLSv5SE4 UYt0ax26aZZYRuLdO/H/bdxQKDR5K0Vm9IkARBBbrDTFQFHTHZOxS8UcYVaVcs62OUarZVheQds iu1xx25yeNKoRnWpWI8FsPIE3s/uL9mw51DBKzlqGtCxTPDPFScAgjbCs+tGEKnNuz/DtPqoW5p FM+F17q1rXBj8Vx82wHnXQVT0bB5gXCr1zyiGIfaqv4NmoTgdQp56v2HVo7QQXYnnTpGNNOdPuP pybhD96pPKxA== X-Received: by 2002:a05:600c:4e42:b0:49e:63cc:6324 with SMTP id 5b1f17b1804b1-49fc4f85e54mr60071545e9.6.1789777603421; Fri, 18 Sep 2026 17:26:43 -0700 (PDT) X-Received: by 2002:a05:600c:4e42:b0:49e:63cc:6324 with SMTP id 5b1f17b1804b1-49fc4f85e54mr60071295e9.6.1789777603069; Fri, 18 Sep 2026 17:26:43 -0700 (PDT) Received: from kybele-google.c.canonical-req-10660.internal (50.34.62.34.bc.googleusercontent.com. [34.62.34.50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fc56aab7csm67941385e9.1.2026.09.18.17.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 17:26:41 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/1] bnxt_en: Fix memory corruption when FW resources change during ifdown Date: Sat, 19 Sep 2026 00:26:40 +0000 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Cengiz Can via kernel-team From: Cengiz Can Reply-To: Cengiz Can Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Sreekanth Reddy bnxt_set_dflt_rings() assumes that it is always called before any TC has been created. So it doesn't take bp->num_tc into account and assumes that it is always 0 or 1. In the FW resource or capability change scenario, the FW will return flags in bnxt_hwrm_if_change() that will cause the driver to reinitialize and call bnxt_cancel_reservations(). This will lead to bnxt_init_dflt_ring_mode() calling bnxt_set_dflt_rings() and bp->num_tc may be greater than 1. This will cause bp->tx_ring[] to be sized too small and cause memory corruption in bnxt_alloc_cp_rings(). Fix it by properly scaling the TX rings by bp->num_tc in the code paths mentioned above. Add 2 helper functions to determine bp->tx_nr_rings and bp->tx_nr_rings_per_tc. Fixes: ec5d31e3c15d ("bnxt_en: Handle firmware reset status during IF_UP.") Reviewed-by: Kalesh AP Reviewed-by: Andy Gospodarek Signed-off-by: Sreekanth Reddy Signed-off-by: Michael Chan Link: https://patch.msgid.link/20250825175927.459987-2-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski (backported from commit 2747328ba2714f1a7454208dbbc1dc0631990b4a) [bot_kybele: This tree has no bp->num_tc field, so the two helpers use netdev_get_num_tc(bp->dev) (the TC-count analogue used elsewhere, e.g. bnxt_reserve_rings) instead of bp->num_tc; also dropped the unrelated bnxt_cfg_one_usr_fltr/bnxt_cfg_usr_fltrs/bnxt_set_xps_mapping functions that git am spuriously pulled into the conflict block since they belong to other commits and don't exist here.] CVE-2025-39810 Assisted-by: kybele:claude-opus-4.8 Signed-off-by: Cengiz Can --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 24 ++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0b435bd3db9d..e650c85145b3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10218,6 +10218,20 @@ static int bnxt_reinit_after_abort(struct bnxt *bp) return rc; } +static int bnxt_tx_nr_rings(struct bnxt *bp) +{ + int tcs = netdev_get_num_tc(bp->dev); + + return tcs ? bp->tx_nr_rings_per_tc * tcs : bp->tx_nr_rings_per_tc; +} + +static int bnxt_tx_nr_rings_per_tc(struct bnxt *bp) +{ + int tcs = netdev_get_num_tc(bp->dev); + + return tcs ? bp->tx_nr_rings / tcs : bp->tx_nr_rings; +} + static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { int rc = 0; @@ -13062,7 +13076,7 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp) bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); bp->rx_nr_rings = bp->cp_nr_rings; bp->tx_nr_rings_per_tc = bp->cp_nr_rings; - bp->tx_nr_rings = bp->tx_nr_rings_per_tc; + bp->tx_nr_rings = bnxt_tx_nr_rings(bp); } static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) @@ -13093,12 +13107,12 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) bnxt_trim_dflt_sh_rings(bp); else bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; - bp->tx_nr_rings = bp->tx_nr_rings_per_tc; + bp->tx_nr_rings = bnxt_tx_nr_rings(bp); rc = __bnxt_reserve_rings(bp); if (rc) netdev_warn(bp->dev, "Unable to reserve tx rings\n"); - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); if (sh) bnxt_trim_dflt_sh_rings(bp); @@ -13107,7 +13121,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) rc = __bnxt_reserve_rings(bp); if (rc) netdev_warn(bp->dev, "2nd rings reservation failed.\n"); - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { bp->rx_nr_rings++; @@ -13138,7 +13152,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp) if (rc) goto init_dflt_ring_err; - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); bnxt_set_dflt_rfs(bp);