Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F173676475
D28232.id82977.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D28232.id82977.diff
View Options
Index: sys/netinet6/udp6_usrreq.c
===================================================================
--- sys/netinet6/udp6_usrreq.c
+++ sys/netinet6/udp6_usrreq.c
@@ -315,6 +315,7 @@
struct inpcb *last;
struct inpcbhead *pcblist;
struct ip6_moptions *imo;
+ bool inp_locked = false;
/*
* In the event that laddr should be set to the link-local
@@ -365,7 +366,7 @@
* and source-specific multicast. [RFC3678]
*/
imo = inp->in6p_moptions;
- if (imo && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
+ if (imo != NULL) {
struct sockaddr_in6 mcaddr;
int blocked;
@@ -392,8 +393,7 @@
INP_RUNLOCK(inp); /* XXX */
continue;
}
-
- INP_RUNLOCK(inp);
+ inp_locked = true;
}
if (last != NULL) {
struct mbuf *n;
@@ -409,6 +409,8 @@
UDP_PROBE(receive, NULL, last,
ip6, last, uh);
if (udp6_append(last, n, off, fromsa)) {
+ if (inp_locked)
+ INP_RUNLOCK(inp);
/* XXX-BZ do we leak m here? */
*mp = NULL;
return (IPPROTO_DONE);
@@ -426,9 +428,22 @@
* non-shared port. It assumes that an application
* will never clear these options after setting them.
*/
+ if (!inp_locked) {
+ INP_RLOCK(last);
+ if (__predict_false(last->inp_flags2 & INP_FREED)) {
+ INP_RUNLOCK(last);
+ continue;
+ }
+ inp_locked = true;
+ }
if ((last->inp_socket->so_options &
(SO_REUSEPORT|SO_REUSEPORT_LB|SO_REUSEADDR)) == 0)
break;
+
+ if (inp_locked) {
+ INP_RUNLOCK(last);
+ inp_locked = false;
+ }
}
if (last == NULL) {
@@ -441,7 +456,10 @@
UDPSTAT_INC(udps_noportmcast);
goto badunlocked;
}
- INP_RLOCK(last);
+
+ if (!inp_locked)
+ INP_RLOCK(last);
+
if (__predict_true(last->inp_flags2 & INP_FREED) == 0) {
if (nxt == IPPROTO_UDPLITE)
UDPLITE_PROBE(receive, NULL, last, ip6, last, uh);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 28, 4:00 PM (18 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39817385
Default Alt Text
D28232.id82977.diff (1 KB)
Attached To
Mode
D28232: Fix possible panic in udp6_input() due to lack of locking.
Attached
Detach File
Event Timeline
Log In to Comment