lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 2 Jul 2010 14:40:17 +0400
From:	Peter Kosyh <p.kosyh@...il.com>
To:	netdev@...r.kernel.org
Subject: [PATCH] xfrm bugs with mark logic

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)
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ