From nobody Mon Sep 28 11:40:13 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CCE543552B for ; Fri, 21 Aug 2026 23:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787355357; cv=none; b=NmbDi3V3z8gJQ5rjtOoYZ4fzJd9La/1qOUfOaBWfMPvJxrqt6Uap9HXwyiI6UJHIXVZlkFDpPlM+vPm0VCsHx5kbiOwWTOe95PaKubKVnBNXMTcRSipsBZoYxpSBxpLZUZ+z4FcLMV6+MCBl4tp5YWvytZpC/S0IHZxSAzuqglc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787355357; c=relaxed/simple; bh=asd0oGe+4nzxMKLWV335XwiZaTgrY2kiFB5C2LrFQuE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZINlfwIGPWiZrfHnr6RCKndJcxUgU1FaGWv789L/iJ725/4/PqR3G1/e/0N6bUo/85L9W2cxrbsnRsp5p43rrjZufEd4p0AfFxuNSTCMsFSXMCqf3nCeP2WU3ORnDysBt+zcvPNZzV3ditMbY1iYHiEQ1TdVglweKB/WLQPPRRk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to; spf=none smtp.mailfrom=dama.to; dkim=pass (2048-bit key) header.d=dama-to.20251104.gappssmtp.com header.i=@dama-to.20251104.gappssmtp.com header.b=Ub0Jmlk/; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=dama.to Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dama-to.20251104.gappssmtp.com header.i=@dama-to.20251104.gappssmtp.com header.b="Ub0Jmlk/" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-84e04df8c46so1839841b3a.2 for ; Fri, 21 Aug 2026 16:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dama-to.20251104.gappssmtp.com; s=20251104; t=1787355355; x=1787960155; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=I2COMEyacsFGYmJ08hxh+ysp07Ov7pN7X0HAy5vh28A=; b=Ub0Jmlk/pVPpFun5EP+0W014uqr+/Ihzi3pAp/Ksx8mGweHGoTySJgrETjHOLG92vs OqJh8qDHdv96s8yuG5TRIAsym/5Y2wdWEoLMZOGHfeuhMbG4dbP9LcMett22qz5v21X2 rKRYw34Ak/tMhhqNUjRcSzhzdM4B6vaA/Lg9PSBXUChY52V38SBCfzRJ0dhpb7pP1e88 5QVP5s92BgTBjhASS++ruL/261PTbaNKANKpNs6ajzGTfJ7ReKztRMZ/OpICd17tA/KC o39jxKmhtJTorfJrzJ6EJVfnWcZ2xiagmjitS82drD9zhefAXHpiQYKZdLLdM3Uijy7e 5cHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787355355; x=1787960155; h=content-transfer-encoding:mime-version: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=I2COMEyacsFGYmJ08hxh+ysp07Ov7pN7X0HAy5vh28A=; b=RDwgxRORkoKarPdH/9OY+BN8CsQr51lXuABgfiLPTxYzXbksMR6SYbvt9EQ4VKbQWh hLlgwF7VREVOKV/UQMQ7qqXha+GGLEtnZNfKtEdduJV7/9OHiKKGIGqFAj+Z8x0btpwf uwIinyqZuIExitUIoqY/iVvnFgin3VY1BVy9EpR6vq0yxiBDB6YR7b8FNY0wn+p7vxeN vFFDkpRCtREXV1IXI1D+fCSK+qRBRMzBrv9ouYrbtgVkg71LJHaYgHcyjH4OttyX9KKA SC9H1RSq7AoXd1rirSmFFplF4MhMTHZ+SS1uU7LiwF2fLb/oQnJPdEFz2gG/dyQJ7l93 lqJg== X-Forwarded-Encrypted: i=1; AHgh+RpLMxmXuhrI2czabZmZrIBOjYfQpmTbZRHKlgra37ZcL1Rbs8CZeMP6om1nurmihKSZ4bbFrVylV1nAE1c=@vger.kernel.org X-Gm-Message-State: AFuF++nVSqJmdmpwYVL58mD272/RnxfgF/Ba3U/w6TrkaYiGAreOrkMj lphDh7uWWZYmxiB4R4fTN+8/Xk4/VsZNraou12G0FIS7lbRuFUsiBRYN9OCCxXXg8Kg= X-Gm-Gg: AR+sD12IwpppGletIPDkQZcNEDuWzILlLT1amULleoWplsMJhpoEnLKVJUv2Qrn7SEc 6DwYV48qEeqlAM7c1L9e5qytCJ7Zi7Y5en0ejqyvaebDZ8ffmq4oeri6OYj3gwgTRuIMXVwFzjm BVHNIVJ+HcUEYrmgpvqWP/qcmdIbxfPlnc180PWC2INiBpYSuHx1QnjXFiKB+iX397xNitIiVWJ l+JOgR6+KEAZSJ3sxtMUzYuX03SgbyIvooy0/HWoacbyMbgdC2ZgfgsgKlDt41x8097YsjbRi8B HU86GkLNghJAPtmaUyAxQGVy1KJXzm7X9qYm9r09utA/vURW1bZR9odD0BSOx719IuTwWFvusXr Gof5wO/R0/G0MiqAZ0RJj8BwViH41WDh0yepaV/OfRPSkQGl3CZ4Eu4irGPK1vpjBxSMIRhqJ5k EGmdKYNi1nRfYFYm2R7MryvT9dBMbG7nkSCV3J6E8NLw== X-Received: by 2002:a05:6a00:a225:b0:847:8b11:5966 with SMTP id d2e1a72fcca58-851f9a8e890mr12978803b3a.1.1787355355122; Fri, 21 Aug 2026 16:35:55 -0700 (PDT) Received: from localhost ([2a03:2880:2ff:58::]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc15523b579sm3637919a12.3.2026.08.21.16.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 16:35:54 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org, Michael Chan , Pavan Chebbi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Kalesh AP , Colin Winegarden Cc: horms@kernel.org, rukhsana.ansari@broadcom.com, linux-kernel@vger.kernel.org, Joe Damato , stable@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH net] bnxt_en: Bound SW TPA IDs to prevent crashes Date: Fri, 21 Aug 2026 16:35:48 -0700 Message-ID: <20260821233549.3134699-1-joe@dama.to> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" TPA IDs are generated by FW and can be up to 1024. bnxt_alloc_agg_idx is intended to wrap the FW ID to a value in the range of [0, 255] and generate a mapping between FW IDs and the wrapped software ID. On a 57608 with firmware version 233, the firmware advertises 32 concurrent TPAs. As of the commit under fixes, bp->max_tpa on this NIC is set to 32. If the software ID from bnxt_alloc_agg_idx is above 31, this results in an invalid address being loaded on this line: tpa_info =3D &rxr->rx_tpa[agg_id]; because rx_tpa is allocated with only bp->max_tpa (32) entries. Writes to tpa_info later in the code are out of bounds. This bug results in a crash at boot: Oops: general protection fault, kernel NULL pointer dereference 0x8: 0000 [= #1] SMP NOPTI RIP: 0010:bnxt_rx_pkt+0xc0/0x1560 RSP: 0018:ffffc900009b8c78 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000048 RCX: 0000000206682516 RDX: ffffc900009b8db4 RSI: 0000000000000000 RDI: 01ffffff038fe1c0 RBP: ffffc9006e687480 R08: ffffc9006e687000 R09: 0000000000003048 R10: 0000000000000480 R11: ffff8881c6083900 R12: 0000000006682516 R13: ffff8881c6095400 R14: 0000000000000016 R15: ffff8881c6b66680 FS: 0000000000000000(0000) GS:ffff88fef3c77000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fc8bda40584 CR3: 000000807c812001 CR4: 0000000008772ef0 PKRU: 55555554 Call Trace: ? __netif_receive_skb_list_core+0x1ca/0x250 __bnxt_poll_work+0x152/0x280 bnxt_poll_p5+0x1cd/0x480 __napi_poll+0x30/0x180 net_rx_action+0x20b/0x3b0 ? note_gp_changes+0x53/0xe0 ? tick_setup_sched_timer+0x180/0x180 ? __napi_schedule+0x9a/0xb0 ? bnxt_msix+0x24/0x30 handle_softirqs+0xdd/0x2c0 __irq_exit_rcu.llvm.3171231171502365008+0x47/0xf0 common_interrupt+0x85/0x90 asm_common_interrupt+0x22/0x40 This stack trace is from a crash triggered when an out of bounds rx_tpa is dereferenced. The invalid write mentioned above is silent in this particular crash. Fix this by adjusting bnxt_alloc_agg_idx so that any SW index greater than or equal to bp->max_tpa goes through the collision logic and picks the first available bit. Adjust the collision logic to only provide bits within the range of [0, bp->max_tpa). Fixes: 54c28fab2fa5 ("bnxt_en: Set bp->max_tpa according to what the FW sup= ports") Cc: stable@vger.kernel.org Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index d3cb25abb632..f348fb93047d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1517,14 +1517,15 @@ static int bnxt_discard_rx(struct bnxt *bp, struct = bnxt_cp_ring_info *cpr, return 0; } =20 -static u16 bnxt_alloc_agg_idx(struct bnxt_rx_ring_info *rxr, u16 agg_id) +static u16 bnxt_alloc_agg_idx(struct bnxt *bp, struct bnxt_rx_ring_info *r= xr, + u16 agg_id) { struct bnxt_tpa_idx_map *map =3D rxr->rx_tpa_idx_map; u16 idx =3D agg_id & MAX_TPA_P5_MASK; =20 - if (test_bit(idx, map->agg_idx_bmap)) { - idx =3D find_first_zero_bit(map->agg_idx_bmap, MAX_TPA_P5); - if (idx >=3D MAX_TPA_P5) + if (idx >=3D bp->max_tpa || test_bit(idx, map->agg_idx_bmap)) { + idx =3D find_first_zero_bit(map->agg_idx_bmap, bp->max_tpa); + if (idx >=3D bp->max_tpa) return INVALID_HW_RING_ID; } __set_bit(idx, map->agg_idx_bmap); @@ -1589,7 +1590,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bn= xt_rx_ring_info *rxr, =20 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { agg_id =3D TPA_START_AGG_ID_P5(tpa_start); - agg_id =3D bnxt_alloc_agg_idx(rxr, agg_id); + agg_id =3D bnxt_alloc_agg_idx(bp, rxr, agg_id); if (unlikely(agg_id =3D=3D INVALID_HW_RING_ID)) { netdev_warn(bp->dev, "Unable to allocate agg ID for ring %d, agg 0x%x\n= ", rxr->bnapi->index, base-commit: 4e15e89faac9f308baeb01f46c13a051814d2449 --=20 2.53.0-Meta