From 679d3c9ff054e4167f70ad3ad5e57d9539a0203a Mon Sep 17 00:00:00 2001
From: Zhenlei Huang <zlei@FreeBSD.org>
Date: Tue, 21 Jan 2025 17:58:18 +0800
Subject: [PATCH] bnxt_en: Add asserting for OOB write to on-stack allocated
 variable app[128]

---
 sys/dev/bnxt/bnxt_en/bnxt_dcb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/bnxt/bnxt_en/bnxt_dcb.c b/sys/dev/bnxt/bnxt_en/bnxt_dcb.c
index e1e0581d3c24..6bcc259d35da 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_dcb.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_dcb.c
@@ -351,6 +351,7 @@ bnxt_hwrm_get_dcbx_app(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *
 
 	n = data->count;
 	for (i = 0; i < n; i++, fw_app++) {
+		MPASS(*num_inputs < 128);
 		app[*num_inputs].priority = fw_app->priority;
 		app[*num_inputs].protocol = htobe16(fw_app->protocol_id);
 		app[*num_inputs].selector = fw_app->protocol_selector;
@@ -504,6 +505,7 @@ bnxt_hwrm_queue_dscp2pri_qcfg(struct bnxt_softc *softc, struct bnxt_dcb_app *app
 
 	entry_cnt =  le16toh(resp->entry_cnt);
 	for (i = 0; i < entry_cnt; i++) {
+		MPASS(*num_inputs < 128);
 		app[*num_inputs].priority = dscp2pri[i].pri;
 		app[*num_inputs].protocol = dscp2pri[i].dscp;
 		app[*num_inputs].selector = BNXT_IEEE_8021QAZ_APP_SEL_DSCP;
-- 
2.46.2