summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorsyrinx <syrinx@FreeBSD.org>2009-09-07 16:00:33 +0000
committersyrinx <syrinx@FreeBSD.org>2009-09-07 16:00:33 +0000
commit805d7d8fea68af484aa35776ec62bc643e0598f8 (patch)
tree16eeb9c1df9cc5e49861df5dd4120535c33d27cf /sys/netinet
parent6032c99a9729fdc9f02f838161f7060d02a78773 (diff)
downloadFreeBSD-src-805d7d8fea68af484aa35776ec62bc643e0598f8.zip
FreeBSD-src-805d7d8fea68af484aa35776ec62bc643e0598f8.tar.gz
When joining a multicast group, the inp_lookup_mcast_ifp call
does a KASSERT that the group address is multicast, so the check if this is indeed true and eventually return a EINVAL if not, should be done before calling inp_lookup_mcast_ifp. This fixes a kernel crash when calling setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,...) with invalid group address. Reviewed by: bms Approved by: bms MFC after: 3 days
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_mcast.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index d0e1397..9a82821 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -1899,6 +1899,9 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
ssa->sin.sin_addr = mreqs.imr_sourceaddr;
}
+ if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr)))
+ return (EINVAL);
+
ifp = inp_lookup_mcast_ifp(inp, &gsa->sin,
mreqs.imr_interface);
CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
@@ -1936,6 +1939,9 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
ssa->sin.sin_port = 0;
}
+ if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr)))
+ return (EINVAL);
+
if (gsr.gsr_interface == 0 || V_if_index < gsr.gsr_interface)
return (EADDRNOTAVAIL);
ifp = ifnet_byindex(gsr.gsr_interface);
@@ -1948,9 +1954,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
break;
}
- if (!IN_MULTICAST(ntohl(gsa->sin.sin_addr.s_addr)))
- return (EINVAL);
-
if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0)
return (EADDRNOTAVAIL);
OpenPOWER on IntegriCloud