netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Subject: Re: [PATCH RESEND] ipv6: add anti-spoofing checks for 6to4 and 6rd
Date: Thu, 24 Jan 2013 12:59:30 +0900	[thread overview]
Message-ID: <5100B1A2.3000908@linux-ipv6.org> (raw)
In-Reply-To: <20130123100248.GB7317@order.stressinduktion.org>

(2013年01月23日 19:02), Hannes Frederic Sowa wrote:
> This patch adds anti-spoofing checks in sit.c as specified in RFC3964
> section 5.2 for 6to4 and RFC5969 section 12 for 6rd. I left out the
> checks which could easily be implemented with netfilter.
> 
> Specifically this patch adds following logic (based loosely on the
> pseudocode in RFC3964 section 5.2):
> 
> if prefix (inner_src_v6) == rd6_prefix (2002::/16 is the default)
>         and outer_src_v4 != embedded_ipv4 (inner_src_v6)
>                 drop
> if prefix (inner_dst_v6) == rd6_prefix (or 2002::/16 is the default)
>         and outer_dst_v4 != embedded_ipv4 (inner_dst_v6)
>                 drop
> accept
> 
> To accomplish the specified security checks proposed by above RFCs,
> it is still necessary to employ uRPF filters with netfilter. These new
> checks only kick in if the employed addresses are within the 2002::/16 or
> another range specified by the 6rd-prefix (which defaults to 2002::/16).
> 
> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Cc: David Miller <davem@davemloft.net>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
>  net/ipv6/sit.c | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index cfba99b..5a09f13 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -73,6 +73,8 @@ static int ipip6_tunnel_init(struct net_device *dev);
>  static void ipip6_tunnel_setup(struct net_device *dev);
>  static void ipip6_dev_free(struct net_device *dev);
>  static struct rtnl_link_ops sit_link_ops __read_mostly;
> +static inline __be32 try_6rd(const struct in6_addr *v6dst,
> +			     struct ip_tunnel *tunnel);
>  
>  static int sit_net_id __read_mostly;
>  struct sit_net {
> @@ -590,6 +592,22 @@ out:
>  	return err;
>  }
>  
> +static int sit_chk_encap_addr(struct ip_tunnel *tunnel, const __be32 *addr,
> +			      const struct in6_addr *addr6)
> +{
> +#ifdef CONFIG_IPV6_SIT_6RD
> +	if (ipv6_prefix_equal(addr6, &tunnel->ip6rd.prefix,
> +			      tunnel->ip6rd.prefixlen) &&
> +	    *addr != try_6rd(addr6, tunnel))
> +		return 0;
> +#else
> +	if (addr6->s6_addr16[0] == htons(0x2002) &&
> +	    *addr != try_6rd(addr6, tunnel))
> +		return 0;
> +#endif
> +	return 1;
> +}
> +

I need to do more research.  I am still not convinced
to have such destination check here because the standard
seems silent about it, and we have several basic checks
in standard input path and tunnel search.


Anyway, try_6rd() can do check for prefix as well
but we are doing slightly different thing.
So I think we can introduce new __check_6rd() to
return non-6rd/6to4 addresses.

bool __check_6rd(struct ip_tunnel *tunnel,
		 const struct in6_addr *v6dst,
		 __be32 *v4dst);

If prefix matches, fill *v4dst and return true.
Otherwise, return false.

__be32 __try_6rd()
{
	__be32 dst = 0;
	__check_6rd(tunnel, v6dst, &dst);
	return dst;
}

--yoshfuji

  reply	other threads:[~2013-01-24  3:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 10:02 [PATCH RESEND] ipv6: add anti-spoofing checks for 6to4 and 6rd Hannes Frederic Sowa
2013-01-24  3:59 ` YOSHIFUJI Hideaki [this message]
2013-01-24 13:55   ` Hannes Frederic Sowa
2013-01-29  4:10   ` Hannes Frederic Sowa
2013-01-29 15:23     ` YOSHIFUJI Hideaki
2013-06-27 13:49 ` Roman Mamedov
2013-06-27 14:19   ` Hannes Frederic Sowa
2013-06-27 15:08     ` Hannes Frederic Sowa

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=5100B1A2.3000908@linux-ipv6.org \
    --to=yoshfuji@linux-ipv6.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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).