summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2004-07-27 16:35:09 +0000
committeryar <yar@FreeBSD.org>2004-07-27 16:35:09 +0000
commit8feaacec0cd088d29781dc3559e0d2adef8602a3 (patch)
tree389610a7debbe1e18a01aefa315920267fd8dcf8 /sys/netinet6
parent1fea905f48b810e78f2b9c5eafe9cec45fcfdf2a (diff)
downloadFreeBSD-src-8feaacec0cd088d29781dc3559e0d2adef8602a3.zip
FreeBSD-src-8feaacec0cd088d29781dc3559e0d2adef8602a3.tar.gz
Don't consider TCP connections beyond LISTEN state
(i.e. with the foreign address being not wildcard) when checking for possible port theft since such connections cannot be stolen. The port theft check is FreeBSD-specific and isn't in the KAME tree. PR: bin/65928 (in the audit trail) Reviewed by: -net, -hackers (silence) Tested by: Nick Leuta <skynick at mail.sc.ru> MFC after: 1 month
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_pcb.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 16a4555..8a66e4f 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -194,14 +194,10 @@ in6_pcbbind(inp, nam, cred)
t = in6_pcblookup_local(pcbinfo,
&sin6->sin6_addr, lport,
INPLOOKUP_WILDCARD);
- if (t && (t->inp_vflag & INP_TIMEWAIT)) {
- if ((!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
- !IN6_IS_ADDR_UNSPECIFIED(&t->in6p_laddr) ||
- !(intotw(t)->tw_so_options & SO_REUSEPORT))
- && so->so_cred->cr_uid !=
- intotw(t)->tw_cred->cr_uid)
- return (EADDRINUSE);
- } else if (t &&
+ if (t &&
+ ((t->inp_vflag & INP_TIMEWAIT) == 0) &&
+ (so->so_type != SOCK_STREAM ||
+ IN6_IS_ADDR_UNSPECIFIED(&t->in6p_faddr)) &&
(!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
!IN6_IS_ADDR_UNSPECIFIED(&t->in6p_laddr) ||
(t->inp_socket->so_options & SO_REUSEPORT)
@@ -216,17 +212,12 @@ in6_pcbbind(inp, nam, cred)
t = in_pcblookup_local(pcbinfo,
sin.sin_addr, lport,
INPLOOKUP_WILDCARD);
- if (t && (t->inp_vflag & INP_TIMEWAIT)) {
- if (so->so_cred->cr_uid !=
- intotw(t)->tw_cred->cr_uid &&
- (ntohl(t->inp_laddr.s_addr) !=
- INADDR_ANY ||
- ((inp->inp_vflag &
- INP_IPV6PROTO) ==
- (t->inp_vflag &
- INP_IPV6PROTO))))
- return (EADDRINUSE);
- } else if (t &&
+ if (t &&
+ ((t->inp_vflag &
+ INP_TIMEWAIT) == 0) &&
+ (so->so_type != SOCK_STREAM ||
+ ntohl(t->inp_faddr.s_addr) ==
+ INADDR_ANY) &&
(so->so_cred->cr_uid !=
t->inp_socket->so_cred->cr_uid) &&
(ntohl(t->inp_laddr.s_addr) !=
OpenPOWER on IntegriCloud