git: c78ab620bb1f - stable/14 - ifnet: Restore previous size of if_afdata
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Aug 2026 20:25:21 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=c78ab620bb1fed047451babc6921732a5d091e4c
commit c78ab620bb1fed047451babc6921732a5d091e4c
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-08-14 08:23:47 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-08-16 20:25:00 +0000
ifnet: Restore previous size of if_afdata
Struct ifnet contains an array if_afdata of AF_MAX pointers to address
information for each possible address family. Since 2013, when AF_MAX
was inadvertently changed to be equal to the highest possible value,
instead of one more than the highest possible value, this array has been
too small in theory, but this never mattered in practice because the
higher address families were not assignable to interfaces.
My recent commit which corrected the value of AF_MAX had the side effect
of breaking the KBI by changing the size and layout of struct ifnet.
This manifested itself as kernel panics when using third-party network
drivers and went unnoticed in main because if_afdata no longer exists
there. Address the issue for stable/15 and stable/14 by keeping the
correct value of AF_MAX but deliberately making if_afdata off by one,
restoring its previous size.
Fixes: ddd850aa7720 ("sys/socket.h: Fix AF_MAX")
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D58840
---
sys/net/if.c | 2 +-
sys/net/if_private.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/net/if.c b/sys/net/if.c
index b3ab75144460..7856f53a3cea 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1123,7 +1123,7 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
struct ifaddr *ifa;
int i;
struct domain *dp;
- void *if_afdata[AF_MAX];
+ void *if_afdata[nitems(ifp->if_afdata)];
#ifdef VIMAGE
bool shutdown;
diff --git a/sys/net/if_private.h b/sys/net/if_private.h
index 8802b08c6a05..b605f5342abe 100644
--- a/sys/net/if_private.h
+++ b/sys/net/if_private.h
@@ -103,7 +103,7 @@ struct ifnet {
void *if_hw_addr; /* hardware link-level address */
const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
struct mtx if_afdata_lock;
- void *if_afdata[AF_MAX];
+ void *if_afdata[AF_MAX - 1]; /* off by one for historical reasons */
int if_afdata_initialized;
/* Additional features hung off the interface. */