lkml.org 
[lkml]   [2000]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectDon't allow mapped address after binding to ipv4.
From
Date
Hi forks,

linux-2.2.16 and linux-2.4.0-test5 allow to let an application bind an
inet6 socket sd6 to an address / a port that is already bound to inet
socket sd4. For example, the 2nd step below should fail.

1. bind sd4 to 127.0.0.1
2. bind sd6 to ::ffff:127.0.0.1

Here a patch to fix this problem (for 2.2.16; maybe for 2.4.0-test5).
Thanks in advance.

diff -u linux-2.2.16/net/ipv6/tcp_ipv6.c linux-2.2.16-fix/net/ipv6/tcp_ipv6.c
--- linux-2.2.16/net/ipv6/tcp_ipv6.c Thu May 4 09:16:53 2000
+++ linux-2.2.16-fix/net/ipv6/tcp_ipv6.c Fri Aug 4 01:08:18 2000
@@ -140,7 +140,12 @@
!ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr,
sk2->state != TCP_TIME_WAIT ?
&sk2->net_pinfo.af_inet6.rcv_saddr :
- &((struct tcp_tw_bucket*)sk)->v6_rcv_saddr))
+ &((struct tcp_tw_bucket*)sk)->v6_rcv_saddr) ||
+ (addr_type == IPV6_ADDR_MAPPED && sk2->family == AF_INET &&
+ sk->rcv_saddr == (sk2->state != TCP_TIME_WAIT ?
+ sk2->rcv_saddr : ((struct tcp_tw_bucket*)sk)->rcv_saddr)
+ )
+ )
break;
}
}
diff -u linux-2.2.16/net/ipv6/udp.c linux-2.2.16-fix/net/ipv6/udp.c
--- linux-2.2.16/net/ipv6/udp.c Tue Aug 10 04:04:41 1999
+++ linux-2.2.16-fix/net/ipv6/udp.c Fri Aug 4 11:29:24 2000
@@ -105,7 +105,9 @@
(!sk2->rcv_saddr ||
addr_type == IPV6_ADDR_ANY ||
!ipv6_addr_cmp(&sk->net_pinfo.af_inet6.rcv_saddr,
- &sk2->net_pinfo.af_inet6.rcv_saddr)) &&
+ &sk2->net_pinfo.af_inet6.rcv_saddr) ||
+ (addr_type == IPV6_ADDR_MAPPED && sk2->family == AF_INET &&
+ sk->rcv_saddr == sk2->rcv_saddr)) &&
(!sk2->reuse || !sk->reuse))
goto fail;
}
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@v6.linux.or.jp>
Web Page: http://www.ecei.tohoku.ac.jp/%7Eyoshfuji/
PGP5i FP: F731 6599 5EB2 BBA7 1515 1323 1806 A96F 5700 6B25

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.147 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site