Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167816703
D57961.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D57961.diff
View Options
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -949,15 +949,18 @@
* can only be used to share a port among sockets owned
* by the same user.
*
- * However, we can share a port with a connected socket
- * which has a unique 4-tuple.
+ * With TCP sockets (SOCK_STREAM) port theft by an
+ * existing connected socket is not possible, but
+ * sharing same local port by different owners is a
+ * legitimate use by ftpd, thus we resort to checking
+ * the wild hash only. See bug 65928 and 4658dc8325e03.
*/
t = in_pcblookup_local(inp->inp_pcbinfo, laddr, lport,
- RT_ALL_FIBS, INPLOOKUP_WILDCARD, cred);
- if (t != NULL &&
- (inp->inp_socket->so_type != SOCK_STREAM ||
- in_nullhost(t->inp_faddr)) &&
- (inp->inp_cred->cr_uid != t->inp_cred->cr_uid))
+ RT_ALL_FIBS,
+ inp->inp_socket->so_type == SOCK_STREAM ? 0 :
+ INPLOOKUP_WILDCARD, cred);
+ if (t != NULL && t->inp_cred->cr_uid !=
+ inp->inp_cred->cr_uid)
return (EADDRINUSE);
}
t = in_pcblookup_local(inp->inp_pcbinfo, laddr, lport, fib,
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -238,21 +238,22 @@
if (!IN6_IS_ADDR_MULTICAST(laddr) &&
priv_check_cred(inp->inp_cred, PRIV_NETINET_REUSEPORT) !=
0) {
+ int credflags;
+
/*
* If a socket owned by a different user is already
* bound to this port, fail. In particular, SO_REUSE*
* can only be used to share a port among sockets owned
* by the same user.
*
- * However, we can share a port with a connected socket
- * which has a unique 4-tuple.
+ * See comment on SOCK_STREAM in in_pcbbind_avail().
*/
+ credflags = inp->inp_socket->so_type == SOCK_STREAM ?
+ 0 : INPLOOKUP_WILDCARD;
t = in6_pcblookup_local(inp->inp_pcbinfo, laddr, lport,
- RT_ALL_FIBS, INPLOOKUP_WILDCARD, cred);
- if (t != NULL &&
- (inp->inp_socket->so_type != SOCK_STREAM ||
- IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) &&
- (inp->inp_cred->cr_uid != t->inp_cred->cr_uid))
+ RT_ALL_FIBS, credflags, cred);
+ if (t != NULL && t->inp_cred->cr_uid !=
+ inp->inp_cred->cr_uid)
return (EADDRINUSE);
#ifdef INET
@@ -263,12 +264,9 @@
in6_sin6_2_sin(&sin, sin6);
t = in_pcblookup_local(inp->inp_pcbinfo,
sin.sin_addr, lport, RT_ALL_FIBS,
- INPLOOKUP_WILDCARD, cred);
- if (t != NULL &&
- (inp->inp_socket->so_type != SOCK_STREAM ||
- in_nullhost(t->inp_faddr)) &&
- (inp->inp_cred->cr_uid !=
- t->inp_cred->cr_uid))
+ credflags, cred);
+ if (t != NULL && t->inp_cred->cr_uid !=
+ inp->inp_cred->cr_uid)
return (EADDRINUSE);
}
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 25, 6:37 PM (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37202562
Default Alt Text
D57961.diff (2 KB)
Attached To
Mode
D57961: inpcb: resort to wildcard hash lookup when checking for TCP port conflict
Attached
Detach File
Event Timeline
Log In to Comment