From owner-svn-src-head@freebsd.org Fri Mar 30 21:38:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6ED15F6C53A; Fri, 30 Mar 2018 21:38:54 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 159E081700; Fri, 30 Mar 2018 21:38:54 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D11F684B; Fri, 30 Mar 2018 21:38:54 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2ULcrKe072846; Fri, 30 Mar 2018 21:38:53 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2ULcrjl072844; Fri, 30 Mar 2018 21:38:53 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201803302138.w2ULcrjl072844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 30 Mar 2018 21:38:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331831 - in head/sys: net netinet6 X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/sys: net netinet6 X-SVN-Commit-Revision: 331831 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Mar 2018 21:38:54 -0000 Author: brooks Date: Fri Mar 30 21:38:53 2018 New Revision: 331831 URL: https://svnweb.freebsd.org/changeset/base/331831 Log: 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 Modified: head/sys/net/if.c head/sys/netinet6/in6.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Fri Mar 30 20:27:47 2018 (r331830) +++ head/sys/net/if.c Fri Mar 30 21:38:53 2018 (r331831) @@ -97,6 +97,13 @@ #include +/* + * 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 #include Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Fri Mar 30 20:27:47 2018 (r331830) +++ head/sys/netinet6/in6.c Fri Mar 30 21:38:53 2018 (r331831) @@ -112,6 +112,14 @@ __FBSDID("$FreeBSD$"); #include #include +/* + * 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)