Fix kernel panic while trying to read multicast stream.

When VIMAGE is enabled make sure the "m_pkthdr.rcvif" pointer is set
for all mbufs being input by the IGMP/MLD6 code. Else there will be a
NULL-pointer dereference in the netisr code when trying to set the
VNET based on the incoming mbuf. Add an assert to catch this when
queueing mbufs on a netisr to make debugging of similar cases easier.

Found by:	Vladislav V. Prodan
PR:		244002
Reviewed by:	bz@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2020-02-17 09:46:32 +00:00
parent ed581bf68f
commit bacb11c9ed
3 changed files with 4 additions and 0 deletions

View File

@ -1056,6 +1056,8 @@ netisr_queue_src(u_int proto, uintptr_t source, struct mbuf *m)
if (m != NULL) {
KASSERT(!CPU_ABSENT(cpuid), ("%s: CPU %u absent", __func__,
cpuid));
VNET_ASSERT(m->m_pkthdr.rcvif != NULL,
("%s:%d rcvif == NULL: m=%p", __func__, __LINE__, m));
error = netisr_queue_internal(proto, m, cpuid);
} else
error = ENOBUFS;

View File

@ -303,6 +303,7 @@ igmp_save_context(struct mbuf *m, struct ifnet *ifp)
#ifdef VIMAGE
m->m_pkthdr.PH_loc.ptr = ifp->if_vnet;
#endif /* VIMAGE */
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.flowid = ifp->if_index;
}

View File

@ -283,6 +283,7 @@ mld_save_context(struct mbuf *m, struct ifnet *ifp)
#ifdef VIMAGE
m->m_pkthdr.PH_loc.ptr = ifp->if_vnet;
#endif /* VIMAGE */
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.flowid = ifp->if_index;
}