Stop setting if_linkmib in vlan(4) ifnets.

There are several reasons:
- The structure being exported via IFDATA_LINKSPECIFIC doesn't appear
  to be a standard MIB.
- The structure being exported is private to the kernel and always
  has been.
- No other drivers in common use set the if_linkmib field.
- Because IFDATA_LINKSPECIFIC can be used to overwrite the linkmib
  structure, a privileged user could use it to corrupt internal
  vlan(4) state. [1]

PR:		219472
Reported by:	CTurt <ecturt@gmail.com> [1]
Reviewed by:	kp (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18779
This commit is contained in:
Mark Johnston 2019-01-09 16:47:16 +00:00
parent e1344f3c32
commit 72755d285f

View File

@ -156,7 +156,7 @@ struct vlan_mc_entry {
struct epoch_context mc_epoch_ctx;
};
struct ifvlan {
struct ifvlan {
struct ifvlantrunk *ifv_trunk;
struct ifnet *ifv_ifp;
#define TRUNK(ifv) ((ifv)->ifv_trunk)
@ -164,28 +164,19 @@ struct ifvlan {
void *ifv_cookie;
int ifv_pflags; /* special flags we have set on parent */
int ifv_capenable;
struct ifv_linkmib {
int ifvm_encaplen; /* encapsulation length */
int ifvm_mtufudge; /* MTU fudged by this much */
int ifvm_mintu; /* min transmission unit */
uint16_t ifvm_proto; /* encapsulation ethertype */
uint16_t ifvm_tag; /* tag to apply on packets leaving if */
uint16_t ifvm_vid; /* VLAN ID */
uint8_t ifvm_pcp; /* Priority Code Point (PCP). */
} ifv_mib;
int ifv_encaplen; /* encapsulation length */
int ifv_mtufudge; /* MTU fudged by this much */
int ifv_mintu; /* min transmission unit */
uint16_t ifv_proto; /* encapsulation ethertype */
uint16_t ifv_tag; /* tag to apply on packets leaving if */
uint16_t ifv_vid; /* VLAN ID */
uint8_t ifv_pcp; /* Priority Code Point (PCP). */
struct task lladdr_task;
CK_SLIST_HEAD(, vlan_mc_entry) vlan_mc_listhead;
#ifndef VLAN_ARRAY
CK_SLIST_ENTRY(ifvlan) ifv_list;
#endif
};
#define ifv_proto ifv_mib.ifvm_proto
#define ifv_tag ifv_mib.ifvm_tag
#define ifv_vid ifv_mib.ifvm_vid
#define ifv_pcp ifv_mib.ifvm_pcp
#define ifv_encaplen ifv_mib.ifvm_encaplen
#define ifv_mtufudge ifv_mib.ifvm_mtufudge
#define ifv_mintu ifv_mib.ifvm_mintu
/* Special flags we should propagate to parent. */
static struct {
@ -1049,10 +1040,6 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
strlcpy(ifp->if_xname, name, IFNAMSIZ);
ifp->if_dname = vlanname;
ifp->if_dunit = unit;
/* NB: flags are not set here */
ifp->if_linkmib = &ifv->ifv_mib;
ifp->if_linkmiblen = sizeof(ifv->ifv_mib);
/* NB: mtu is not set here */
ifp->if_init = vlan_init;
ifp->if_transmit = vlan_transmit;