Do not use loopback as source address on other interfaces
Subsystems (3)
PATCH 1/1 Do not use loopback as source address on other interfaces
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
--- net/ipv6/icmp.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
net/ipv6/icmp.c +4 -1
@@ -698,7 +698,10 @@ static int icmpv6_rcv(struct sk_buff *skb)switch (type) {case ICMPV6_ECHO_REQUEST : -icmpv6_echo_reply (skb); +/* check that the query is not for loopback address (PSE SPB) */ +if (!(ipv6_addr_type (daddr) &IPV6_ADDR_LOOPBACK ) || + (dev->flags &IFF_LOOPBACK )) +icmpv6_echo_reply (skb);break ;case ICMPV6_ECHO_REPLY :
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
In article <[email protected]> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <[email protected]> says:
Quoted 8 lines
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
Signed-off-by Sergey Mironov <[email protected]>Signed-off-by Karsten Keil <[email protected]>
I disagree this approach - too ad-hoc fix just to pass the tests.
--yoshfuji
Quoted 5 lines · YOSHIFUJI Hideaki / 吉藤英明
In article <[email protected]> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <[email protected]> says:
Quoted 3 lines
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
Quoted 8 lines
Quoted 5 lines
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
Signed-off-by Sergey Mironov <[email protected]>Signed-off-by Karsten Keil <[email protected]>I disagree this approach - too ad-hoc fix just to pass the tests.
So you would prefer a more general test in some common place (like __ip6_local_out() ) to avoid any packets with ::1 on other devices as loopback ?
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Quoted 12 lines · Karsten Keil
Quoted 11 lines · YOSHIFUJI Hideaki / 吉藤英明
In article <[email protected]> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <[email protected]> says:
Quoted 8 lines
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
Signed-off-by Sergey Mironov <[email protected]>Signed-off-by Karsten Keil <[email protected]>
Quoted 7 lines
Quoted 2 lines
I disagree this approach - too ad-hoc fix just to pass the tests.
So you would prefer a more general test in some common place (like
__ip6_local_out()) to avoid any packets with ::1 on other devices as loopback ?
I think that dropping pakets with destination ::1 in ipv6_rcv() for devices != loopback would be better reflect what RFC 4291 2.5.3 says.
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
In article <[email protected]> (at Wed, 18 Jun 2008 16:05:58 +0200), Karsten Keil <[email protected]> says:
Quoted 12 lines · YOSHIFUJI Hideaki / 吉藤英明
Quoted 11 lines
In article <[email protected]> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <[email protected]> says:
Quoted 8 lines
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
Signed-off-by Sergey Mironov <[email protected]>Signed-off-by Karsten Keil <[email protected]>
Quoted 6 lines
Quoted 2 lines
I disagree this approach - too ad-hoc fix just to pass the tests.
So you would prefer a more general test in some common place (like
__ip6_local_out()) to avoid any packets with ::1 on other devices as loopback ?
No, we should not even accept packets for ::1 from outside of the box. Something like this.
---
ipv6: Drop packets for loopback address from outside of the box.
include/net/ipv6.h +6 -0
@@ -367,6 +367,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a) a->s6_addr32[2] | a->s6_addr32[3] ) == 0); } +static inline int ipv6_addr_loopback (const struct in6_addr *a) +{ +return ((a->s6_addr32[0 ] | a->s6_addr32[1 ] | + a->s6_addr32[2 ] | (a->s6_addr32[3 ] ^htonl (1 ))) ==0 ); +} +static inline int ipv6_addr_v4mapped (const struct in6_addr *a) { return ((a->s6_addr32[0] | a->s6_addr32[1] |
net/ipv6/ip6_input.c +9 -0
@@ -102,6 +102,15 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptif (hdr->version !=6 ) goto err; +/* +* RFC4291 2.5.3 +* A packet received on an interface with a destination address +* of loopback must be dropped. +*/ +if (!(dev->flags &IFF_LOOPBACK ) && +ipv6_addr_loopback (&hdr->daddr)) + goto err; + skb->transport_header = skb->network_header +sizeof (*hdr);IP6CB (skb)->nhoff = offsetof(struct ipv6hdr , nexthdr);
--yoshfuji
Quoted 17 lines · YOSHIFUJI Hideaki / 吉藤英明
In article <[email protected]> (at Wed, 18 Jun 2008 16:05:58 +0200), Karsten Keil <[email protected]> says:
Quoted 15 lines · YOSHIFUJI Hideaki / 吉藤英明
Quoted 13 lines
In article <[email protected]> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <[email protected]> says:
Quoted 8 lines
RFC 4291 forbit the use of the loopback address as source outside a node (paragraph 2.5.3).
The latest TAHI test release 4.0.1 does have a check for this (ICMPv6 test v6LC.5.1.2 Part F), so it fails currently on Linux.
Signed-off-by Sergey Mironov <[email protected]>Signed-off-by Karsten Keil <[email protected]>I disagree this approach - too ad-hoc fix just to pass the tests.
Quoted 7 lines
Quoted 3 lines
So you would prefer a more general test in some common place (like
__ip6_local_out()) to avoid any packets with ::1 on other devices as loopback ?No, we should not even accept packets for ::1 from outside of the box. Something like this.
Yes I was thinking about nearly the same patch now :-)
Quoted 46 lines
---
ipv6: Drop packets for loopback address from outside of the box.Signed-off-by YOSHIFUJI Hideaki <[email protected]>include/net/ipv6.h +6
-0@@ -367,6 +367,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a) a->s6_addr32[2] | a->s6_addr32[3] ) == 0); } +static inline int ipv6_addr_loopback (const struct in6_addr *a) +{ +return ((a->s6_addr32[0 ] | a->s6_addr32[1 ] | + a->s6_addr32[2 ] | (a->s6_addr32[3 ] ^htonl (1 ))) ==0 ); +} +static inline int ipv6_addr_v4mapped (const struct in6_addr *a) { return ((a->s6_addr32[0] | a->s6_addr32[1] |net/ipv6/ip6_input.c +9
-1@@ -102,6 +102,15 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptif (hdr->version !=6 ) goto err; +/* +* RFC4291 2.5.3 +* A packet received on an interface with a destination address +* of loopback must be dropped. +*/ +if (!(dev->flags &IFF_LOOPBACK ) && +ipv6_addr_loopback (&hdr->daddr)) + goto err; + skb->transport_header = skb->network_header +sizeof (*hdr);IP6CB (skb)->nhoff = offsetof(struct ipv6hdr , nexthdr); --yoshfuji
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Hi Yoshfuji,
On Wed, Jun 18, 2008 at 11:36:07PM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
Verified that this patch fix the TAHI issue and that ping6 ::1 still works. So this should go in.
...
Quoted 49 lines
ipv6: Drop packets for loopback address from outside of the box.
Signed-off-by YOSHIFUJI Hideaki <[email protected]>include/net/ipv6.h +6
-0@@ -367,6 +367,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a) a->s6_addr32[2] | a->s6_addr32[3] ) == 0); } +static inline int ipv6_addr_loopback (const struct in6_addr *a) +{ +return ((a->s6_addr32[0 ] | a->s6_addr32[1 ] | + a->s6_addr32[2 ] | (a->s6_addr32[3 ] ^htonl (1 ))) ==0 ); +} +static inline int ipv6_addr_v4mapped (const struct in6_addr *a) { return ((a->s6_addr32[0] | a->s6_addr32[1] |net/ipv6/ip6_input.c +9
-2@@ -102,6 +102,15 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptif (hdr->version !=6 ) goto err; +/* +* RFC4291 2.5.3 +* A packet received on an interface with a destination address +* of loopback must be dropped. +*/ +if (!(dev->flags &IFF_LOOPBACK ) && +ipv6_addr_loopback (&hdr->daddr)) + goto err; + skb->transport_header = skb->network_header +sizeof (*hdr);IP6CB (skb)->nhoff = offsetof(struct ipv6hdr , nexthdr); --yoshfuji --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Karsten Keil SuSE Labs ISDN and VOIP development SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
David Miller
maintainerFrom: Karsten Keil <[email protected]>
Date: Wed, 18 Jun 2008 19:49:07 +0200
Quoted 2 lines
Verified that this patch fix the TAHI issue and that ping6 ::1 still works. So this should go in.
I've added the patch to net-2.6, as below. Thanks everyone!
ipv6: Drop packets for loopback address from outside of the box.
[ Based upon original report and patch by Karsten Keil. Karsten
has verified that this fixes the TAHI test case "ICMPv6 test v6LC.5.1.2 Part F". -DaveM ]
--- include/net/ipv6.h | 6 ++++++ net/ipv6/ip6_input.c | 9 +++++++++ 2 files changed, 15 insertions(+), 0 deletions(-)
include/net/ipv6.h +6 -0
@@ -367,6 +367,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a) a->s6_addr32[2] | a->s6_addr32[3] ) == 0); } +static inline int ipv6_addr_loopback (const struct in6_addr *a) +{ +return ((a->s6_addr32[0 ] | a->s6_addr32[1 ] | + a->s6_addr32[2 ] | (a->s6_addr32[3 ] ^htonl (1 ))) ==0 ); +} +static inline int ipv6_addr_v4mapped (const struct in6_addr *a) { return ((a->s6_addr32[0] | a->s6_addr32[1] |
net/ipv6/ip6_input.c +9 -0
@@ -102,6 +102,15 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptif (hdr->version !=6 ) goto err; +/* +* RFC4291 2.5.3 +* A packet received on an interface with a destination address +* of loopback must be dropped. +*/ +if (!(dev->flags &IFF_LOOPBACK ) && +ipv6_addr_loopback (&hdr->daddr)) + goto err; + skb->transport_header = skb->network_header +sizeof (*hdr);IP6CB (skb)->nhoff = offsetof(struct ipv6hdr , nexthdr);
Signature · 1 line
1.5.6.rc3.21.g8c6b5