Author: hselasky
Date: Mon Feb 17 09:46:32 2020
New Revision: 358013
URL: https://svnweb.freebsd.org/changeset/base/358013

Log:
  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

Modified:
  head/sys/net/netisr.c
  head/sys/netinet/igmp.c
  head/sys/netinet6/mld6.c

Modified: head/sys/net/netisr.c
==============================================================================
--- head/sys/net/netisr.c       Mon Feb 17 01:59:55 2020        (r358012)
+++ head/sys/net/netisr.c       Mon Feb 17 09:46:32 2020        (r358013)
@@ -1056,6 +1056,8 @@ netisr_queue_src(u_int proto, uintptr_t source, struct
        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;

Modified: head/sys/netinet/igmp.c
==============================================================================
--- head/sys/netinet/igmp.c     Mon Feb 17 01:59:55 2020        (r358012)
+++ head/sys/netinet/igmp.c     Mon Feb 17 09:46:32 2020        (r358013)
@@ -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;
 }
 

Modified: head/sys/netinet6/mld6.c
==============================================================================
--- head/sys/netinet6/mld6.c    Mon Feb 17 01:59:55 2020        (r358012)
+++ head/sys/netinet6/mld6.c    Mon Feb 17 09:46:32 2020        (r358013)
@@ -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;
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to