Page MenuHomeFreeBSD

ifnet: Restore previous size of if_afdata
ClosedPublic

Authored by des on Fri, Aug 14, 8:38 AM.
Tags
None
Referenced Files
F167492468: D58840.id184038.diff
Sat, Aug 22, 6:16 AM
F167491462: D58840.id184044.diff
Sat, Aug 22, 6:00 AM
F167458866: D58840.id.diff
Fri, Aug 21, 9:51 PM
F167413815: D58840.id184038.diff
Fri, Aug 21, 3:11 PM
Unknown Object (File)
Fri, Aug 21, 2:39 PM
Unknown Object (File)
Thu, Aug 20, 8:58 PM
Unknown Object (File)
Thu, Aug 20, 8:46 PM
Unknown Object (File)
Thu, Aug 20, 7:01 PM

Details

Summary

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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Fri, Aug 14, 8:38 AM
sys/net/if_private.h
106

Perhaps I should just hardcode 46 here (44 for stable/14) instead and note in the comment that only AF_INET and AF_INET6 are actually used?

There's also a copy in if_detach_internal that should be resized, this should have tripped a _Static_assert there. (No opinion on the literal)

IMHO, AF_MAX - 1 is better than 44 or 46. The latter will look more cryptic to a reader.

This revision is now accepted and ready to land.Fri, Aug 14, 4:48 PM