From 8a39e7b800c3e1302530f1b61be756b3d627077a Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 12 Apr 2006 03:23:56 +0000 Subject: Add udbinfo locking in udp6_input() to protect lookups of the inpcb lists during UDPv6 receipt. MFC after: 3 months --- sys/netinet6/udp6_usrreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sys/netinet6/udp6_usrreq.c') diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index d551e17..61c8ea1 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -167,13 +167,14 @@ udp6_input(mp, offp, proto) */ if (uh->uh_sum == 0) { udpstat.udps_nosum++; - goto bad; + goto bad_unlocked; } if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) { udpstat.udps_badsum++; - goto bad; + goto bad_unlocked; } + INP_INFO_RLOCK(&udbinfo); if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { struct inpcb *last; @@ -321,6 +322,7 @@ udp6_input(mp, offp, proto) goto bad; } sorwakeup(last->in6p_socket); + INP_INFO_RUNLOCK(&udbinfo); return IPPROTO_DONE; } /* @@ -345,6 +347,7 @@ udp6_input(mp, offp, proto) udpstat.udps_noportmcast++; goto bad; } + INP_INFO_RUNLOCK(&udbinfo); icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); return IPPROTO_DONE; } @@ -376,8 +379,11 @@ udp6_input(mp, offp, proto) goto bad; } sorwakeup(in6p->in6p_socket); + INP_INFO_RUNLOCK(&udbinfo); return IPPROTO_DONE; bad: + INP_INFO_RUNLOCK(&udbinfo); +bad_unlocked: if (m) m_freem(m); if (opts) -- cgit v1.1