summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2004-07-28 13:03:07 +0000
committeryar <yar@FreeBSD.org>2004-07-28 13:03:07 +0000
commit1d71ae12e04f2a1a9ef933f5f3476a7eb8452773 (patch)
tree2a47da9c193ec94019f4bcaf943fc178c30d4918 /sys/netinet/in_pcb.c
parentb124db99c05e37f645b36c9800a2b540c8da0e5b (diff)
downloadFreeBSD-src-1d71ae12e04f2a1a9ef933f5f3476a7eb8452773.zip
FreeBSD-src-1d71ae12e04f2a1a9ef933f5f3476a7eb8452773.tar.gz
Disallow a particular kind of port theft described by the following scenario:
Alice is too lazy to write a server application in PF-independent manner. Therefore she knocks up the server using PF_INET6 only and allows the IPv6 socket to accept mapped IPv4 as well. An evil hacker known on IRC as cheshire_cat has an account in the same system. He starts a process listening on the same port as used by Alice's server, but in PF_INET. As a consequence, cheshire_cat will distract all IPv4 traffic supposed to go to Alice's server. Such sort of port theft was initially enabled by copying the code that implemented the RFC 2553 semantics on IPv4/6 sockets (see inet6(4)) for the implied case of the same owner for both connections. After this change, the above scenario will be impossible. In the same setting, the user who attempts to start his server last will get EADDRINUSE. Of course, using IPv4 mapped to IPv6 leads to security complications in the first place, but there is no reason to make it even more unsafe. This change doesn't apply to KAME since it affects a FreeBSD-specific part of the code. It doesn't modify the out-of-box behaviour of the TCP/IP stack either as long as mapping IPv4 to IPv6 is off by default. MFC after: 1 month
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 9f40419..4e5dbee 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -343,17 +343,8 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, cred)
(t->inp_socket->so_options &
SO_REUSEPORT) == 0) &&
(so->so_cred->cr_uid !=
- t->inp_socket->so_cred->cr_uid)) {
-#if defined(INET6)
- if (ntohl(sin->sin_addr.s_addr) !=
- INADDR_ANY ||
- ntohl(t->inp_laddr.s_addr) !=
- INADDR_ANY ||
- INP_SOCKAF(so) ==
- INP_SOCKAF(t->inp_socket))
-#endif /* defined(INET6) */
+ t->inp_socket->so_cred->cr_uid))
return (EADDRINUSE);
- }
}
if (prison && prison_ip(cred, 0, &sin->sin_addr.s_addr))
return (EADDRNOTAVAIL);
OpenPOWER on IntegriCloud