public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Peter Kosyh <p.kosyh@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] xfrm bugs with mark logic
Date: Fri, 02 Jul 2010 17:01:38 +0200	[thread overview]
Message-ID: <1278082898.2530.37.camel@edumazet-laptop> (raw)
In-Reply-To: <AANLkTimsVHoNk3B1oTI6awlNtrmNED7vwe2flzTap9aP@mail.gmail.com>

Le vendredi 02 juillet 2010 à 14:40 +0400, Peter Kosyh a écrit :
> Hello! I am currently working with 2.6.34, trying to use iptables ...
> -j MARK with XFRM policy. So, i found at least
> two bugs in 2.6.34 kernel.
> 
> First bug is just typo in  xfrm_mark_get (net/xfrm.h):
> 
> memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(m));
> 
> must be:
> 
> memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(*m));
> 
> The second one, is clearing mark in flowi structure via memset in
> _decode_session4 (net/ipv4/xfrm4_policy.c).
> (see net/ipv4/netfilter.c, ip_route_me_harder function)
> int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
> /* ... */
>         if (addr_type == RTN_LOCAL) {
> /* ... */
>                 fl.mark = skb->mark; /* here, set mark from skb */
> /* ... */
> #ifdef CONFIG_XFRM
>         if (!(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) &&
>             xfrm_decode_session(skb, &fl, AF_INET) == 0) { /* here
> fl->mark will be zeroed */
>             /* ... */
>             if (xfrm_lookup(net, &dst, &fl, skb->sk, 0)) /* here
> policy lookup will fail */
> 
> Do not know about ipv6 anything, but it's like that it affected by
> this bug too. :(
> 
> P.S. Sorry for my bad English. :)
> 
> w.b.r. Peter Kosyh
> 
> diff -Nur linux-2.6.34/include/net/xfrm.h linux-2.6.34.fix/include/net/xfrm.h
> --- linux-2.6.34/include/net/xfrm.h	2010-05-16 21:17:36.000000000 +0000
> +++ linux-2.6.34.fix/include/net/xfrm.h	2010-07-02 10:05:33.000000000 +0000
> @@ -1587,7 +1587,7 @@
>  static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
>  {
>  	if (attrs[XFRMA_MARK])
> -		memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(m));
> +		memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(*m));
>  	else
>  		m->v = m->m = 0;
> diff -Nur linux-2.6.34/net/ipv4/xfrm4_policy.c
> linux-2.6.34.fix/net/ipv4/xfrm4_policy.c
> --- linux-2.6.34/net/ipv4/xfrm4_policy.c	2010-05-16 21:17:36.000000000 +0000
> +++ linux-2.6.34.fix/net/ipv4/xfrm4_policy.c	2010-07-02 10:17:51.000000000 +0000
> @@ -186,6 +186,7 @@
>  	fl->fl4_dst = reverse ? iph->saddr : iph->daddr;
>  	fl->fl4_src = reverse ? iph->daddr : iph->saddr;
>  	fl->fl4_tos = iph->tos;
> +	fl->mark = skb->mark;
>  }
> 
>  static inline int xfrm4_garbage_collect(struct dst_ops *ops)
> --

Hi Peter

XFRMA_MARK part already in net-2.6 tree :

http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commit;h=4efd7e833591721bec21cc4730a7f6261417840f

Please submit another patch the second problem you spotted ?





  reply	other threads:[~2010-07-02 15:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-02 10:40 [PATCH] xfrm bugs with mark logic Peter Kosyh
2010-07-02 15:01 ` Eric Dumazet [this message]
2010-07-02 16:24   ` Peter Kosyh
2010-07-02 16:59     ` Eric Dumazet

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=1278082898.2530.37.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=p.kosyh@gmail.com \
    /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