From: "YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>
To: kkeil@suse.de, davem@davemloft.net
Cc: netdev@vger.kernel.org, Mironov_Sergey@emc.com,
akpm@linux-foundation.org, torvalds@linux-foundation.org,
yoshfuji@linux-ipv6.org
Subject: Re: [PATCH] [IPv6] Do not use loopback as source address on other interfaces
Date: Wed, 18 Jun 2008 23:36:07 +0900 (JST) [thread overview]
Message-ID: <20080618.233607.20745708.yoshfuji@linux-ipv6.org> (raw)
In-Reply-To: <20080618140558.GB25004@pingi.kke.suse.de>
In article <20080618140558.GB25004@pingi.kke.suse.de> (at Wed, 18 Jun 2008 16:05:58 +0200), Karsten Keil <kkeil@suse.de> says:
> On Wed, Jun 18, 2008 at 10:36:00PM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
> > In article <20080618132312.GA25004@pingi.kke.suse.de> (at Wed, 18 Jun 2008 15:23:12 +0200), Karsten Keil <kkeil@suse.de> says:
> >
> > > 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 <Mironov_Sergey@emc.com>
> > > Signed-off-by: Karsten Keil <kkeil@suse.de>
> >
> > 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.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
--
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e0a612b..f422f72 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -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] |
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 4e5c861..17eb48b 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -102,6 +102,15 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
if (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
next prev parent reply other threads:[~2008-06-18 14:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-18 13:23 [PATCH] [IPv6] Do not use loopback as source address on other interfaces Karsten Keil
2008-06-18 13:36 ` YOSHIFUJI Hideaki / 吉藤英明
2008-06-18 14:05 ` Karsten Keil
2008-06-18 14:25 ` Karsten Keil
2008-06-18 14:36 ` YOSHIFUJI Hideaki / 吉藤英明 [this message]
2008-06-18 16:11 ` Karsten Keil
2008-06-18 17:49 ` Karsten Keil
2008-06-19 23:34 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080618.233607.20745708.yoshfuji@linux-ipv6.org \
--to=yoshfuji@linux-ipv6.org \
--cc=Mironov_Sergey@emc.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=kkeil@suse.de \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).