瀏覽代碼

IPv6: fix CoA check in RH2 input handler (mip6_rthdr_input())

The input handler for Type 2 Routing Header (mip6_rthdr_input())
checks if the CoA in the packet matches the CoA in the XFRM state.

Current check is buggy: it compares the adddress in the Type 2
Routing Header, i.e. the HoA, against the expected CoA in the state.
The comparison should be made against the address in the destination
field of the IPv6 header.

The bug remained unnoticed because the main (and possibly only current)
user of the code (UMIP MIPv6 Daemon) initializes the XFRM state with the
unspecified address, i.e. explicitly allows everything.

Yoshifuji-san, can you ack that one?

Signed-off-by: Arnaud Ebalard <arno@natisbad.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Arnaud Ebalard 15 年之前
父節點
當前提交
d9a9dc66eb
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      net/ipv6/mip6.c

+ 2 - 1
net/ipv6/mip6.c

@@ -347,11 +347,12 @@ static const struct xfrm_type mip6_destopt_type =
 
 
 static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb)
 static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 {
+	struct ipv6hdr *iph = ipv6_hdr(skb);
 	struct rt2_hdr *rt2 = (struct rt2_hdr *)skb->data;
 	struct rt2_hdr *rt2 = (struct rt2_hdr *)skb->data;
 	int err = rt2->rt_hdr.nexthdr;
 	int err = rt2->rt_hdr.nexthdr;
 
 
 	spin_lock(&x->lock);
 	spin_lock(&x->lock);
-	if (!ipv6_addr_equal(&rt2->addr, (struct in6_addr *)x->coaddr) &&
+	if (!ipv6_addr_equal(&iph->daddr, (struct in6_addr *)x->coaddr) &&
 	    !ipv6_addr_any((struct in6_addr *)x->coaddr))
 	    !ipv6_addr_any((struct in6_addr *)x->coaddr))
 		err = -ENOENT;
 		err = -ENOENT;
 	spin_unlock(&x->lock);
 	spin_unlock(&x->lock);