Path: blob/main/website/static/security/patches/EN-10:01/multicast.patch
18096 views
Index: sys/netinet/raw_ip.c1===================================================================2--- sys/netinet/raw_ip.c (revision 200583)3+++ sys/netinet/raw_ip.c (working copy)4@@ -343,17 +343,35 @@ rip_input(struct mbuf *m, int off)5*/6if (inp->inp_moptions != NULL &&7IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) {8- struct sockaddr_in group;9+ /*10+ * If the incoming datagram is for IGMP, allow it11+ * through unconditionally to the raw socket.12+ *13+ * In the case of IGMPv2, we may not have explicitly14+ * joined the group, and may have set IFF_ALLMULTI15+ * on the interface. imo_multi_filter() may discard16+ * control traffic we actually need to see.17+ *18+ * Userland multicast routing daemons should continue19+ * filter the control traffic appropriately.20+ */21int blocked;2223- bzero(&group, sizeof(struct sockaddr_in));24- group.sin_len = sizeof(struct sockaddr_in);25- group.sin_family = AF_INET;26- group.sin_addr = ip->ip_dst;27+ blocked = MCAST_PASS;28+ if (proto != IPPROTO_IGMP) {29+ struct sockaddr_in group;3031- blocked = imo_multi_filter(inp->inp_moptions, ifp,32- (struct sockaddr *)&group,33- (struct sockaddr *)&ripsrc);34+ bzero(&group, sizeof(struct sockaddr_in));35+ group.sin_len = sizeof(struct sockaddr_in);36+ group.sin_family = AF_INET;37+ group.sin_addr = ip->ip_dst;38+39+ blocked = imo_multi_filter(inp->inp_moptions,40+ ifp,41+ (struct sockaddr *)&group,42+ (struct sockaddr *)&ripsrc);43+ }44+45if (blocked != MCAST_PASS) {46IPSTAT_INC(ips_notmember);47continue;48Index: sys/netinet6/raw_ip6.c49===================================================================50--- sys/netinet6/raw_ip6.c (revision 200583)51+++ sys/netinet6/raw_ip6.c (working copy)52@@ -213,17 +213,39 @@ rip6_input(struct mbuf **mp, int *offp, int proto)53*/54if (in6p->in6p_moptions &&55IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {56- struct sockaddr_in6 mcaddr;57+ /*58+ * If the incoming datagram is for MLD, allow it59+ * through unconditionally to the raw socket.60+ *61+ * Use the M_RTALERT_MLD flag to check for MLD62+ * traffic without having to inspect the mbuf chain63+ * more deeply, as all MLDv1/v2 host messages MUST64+ * contain the Router Alert option.65+ *66+ * In the case of MLDv1, we may not have explicitly67+ * joined the group, and may have set IFF_ALLMULTI68+ * on the interface. im6o_mc_filter() may discard69+ * control traffic we actually need to see.70+ *71+ * Userland multicast routing daemons should continue72+ * filter the control traffic appropriately.73+ */74int blocked;7576- bzero(&mcaddr, sizeof(struct sockaddr_in6));77- mcaddr.sin6_len = sizeof(struct sockaddr_in6);78- mcaddr.sin6_family = AF_INET6;79- mcaddr.sin6_addr = ip6->ip6_dst;80+ blocked = MCAST_PASS;81+ if ((m->m_flags & M_RTALERT_MLD) == 0) {82+ struct sockaddr_in6 mcaddr;8384- blocked = im6o_mc_filter(in6p->in6p_moptions, ifp,85- (struct sockaddr *)&mcaddr,86- (struct sockaddr *)&fromsa);87+ bzero(&mcaddr, sizeof(struct sockaddr_in6));88+ mcaddr.sin6_len = sizeof(struct sockaddr_in6);89+ mcaddr.sin6_family = AF_INET6;90+ mcaddr.sin6_addr = ip6->ip6_dst;91+92+ blocked = im6o_mc_filter(in6p->in6p_moptions,93+ ifp,94+ (struct sockaddr *)&mcaddr,95+ (struct sockaddr *)&fromsa);96+ }97if (blocked != MCAST_PASS) {98IP6STAT_INC(ip6s_notmember);99continue;100101102