[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1278082898.2530.37.camel@edumazet-laptop>
Date: Fri, 02 Jul 2010 17:01:38 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Peter Kosyh <p.kosyh@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH] xfrm bugs with mark logic
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 ?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists