git: d9f4536a0743 - main - bnxt: fix an out-of-bounds write in bnxt_copy_maddr()

From: Bojan Novković <bnovkov_at_FreeBSD.org>
Date: Wed, 25 Nov 2026 15:49:53 UTC
The branch main has been updated by bnovkov:

URL: https://cgit.FreeBSD.org/src/commit/?id=d9f4536a0743ea323e297d45453c38adec9c77bd

commit d9f4536a0743ea323e297d45453c38adec9c77bd
Author:     Greg Becker <becker.greg@att.net>
AuthorDate: 2026-11-25 15:40:04 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2026-11-25 15:48:32 +0000

    bnxt: fix an out-of-bounds write in bnxt_copy_maddr()
    
    bnxt_copy_maddr() copies link-layer multicast addresses into the
    BNXT_MAX_MC_ADDRS-entry list given to the firmware, but only skips the
    copy when cnt == BNXT_MAX_MC_ADDRS.  The callback returns 1 for every
    address, so with 18 or more addresses it writes past the end of the
    list.  bnxt_multi_set() switches to ALL_MCAST when there are more than
    BNXT_MAX_MC_ADDRS addresses, so the extra entries are never used, but
    on amd64 the list sits at the start of a 4 KB allocation, and with 683
    or more addresses the writes go past it.
    
    Skip the copy for every cnt >= BNXT_MAX_MC_ADDRS.
    
    Fixes:          dbf9bf044c6e ("Convert to if_foreach_llmaddr() KPI.")
    MFC after:      2 weeks
    Sponsored by:   E-CARD LTD.
    Sponsored by:   Klara, Inc.
    
    Reviewed by:    sef, gallatin
    Differential Revision:  https://reviews.freebsd.org/D61950
---
 sys/dev/bnxt/bnxt_en/if_bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c
index a1126755345c..3dfc11ca32c8 100644
--- a/sys/dev/bnxt/bnxt_en/if_bnxt.c
+++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -4042,7 +4042,7 @@ bnxt_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
 {
 	uint8_t *mta = arg;
 
-	if (cnt == BNXT_MAX_MC_ADDRS)
+	if (cnt >= BNXT_MAX_MC_ADDRS)
 		return (1);
 
 	bcopy(LLADDR(sdl), &mta[cnt * ETHER_ADDR_LEN], ETHER_ADDR_LEN);