Document and enforce assumptions about struct (in6_)ifreq.
- The two types must be type-punnable for shared members of ifr_ifru. This allows compatibility accessors to be shared. - There must be no padding gap between ifr_name and ifr_ifru. This is assumed in tcpdump's use of SIOCGIFFLAGS output which attempts to be broadly portable. This is true for all current architectures, but very large (256-bit) fat-pointers could violate this invariant. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14910
This commit is contained in:
parent
edde7c6e59
commit
8708f1bdaf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331831
@ -97,6 +97,13 @@
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
/*
|
||||
* Consumers of struct ifreq such as tcpdump assume no pad between ifr_name
|
||||
* and ifr_ifru when it is used in SIOCGIFCONF.
|
||||
*/
|
||||
_Static_assert(sizeof(((struct ifreq *)0)->ifr_name) ==
|
||||
offsetof(struct ifreq, ifr_ifru), "gap between ifr_name and ifr_ifru");
|
||||
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
#include <sys/mount.h>
|
||||
#include <compat/freebsd32/freebsd32.h>
|
||||
|
@ -112,6 +112,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet6/in6_fib.h>
|
||||
#include <netinet6/in6_pcb.h>
|
||||
|
||||
/*
|
||||
* struct in6_ifreq and struct ifreq must be type punnable for common members
|
||||
* of ifr_ifru to allow accessors to be shared.
|
||||
*/
|
||||
_Static_assert(offsetof(struct in6_ifreq, ifr_ifru) ==
|
||||
offsetof(struct ifreq, ifr_ifru),
|
||||
"struct in6_ifreq and struct ifreq are not type punnable");
|
||||
|
||||
VNET_DECLARE(int, icmp6_nodeinfo_oldmcprefix);
|
||||
#define V_icmp6_nodeinfo_oldmcprefix VNET(icmp6_nodeinfo_oldmcprefix)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user