[IPV6]: Disallow RH0 by default.
A security issue is emerging. Disallow Routing Header Type 0 by default as we have been doing for IPv4. Note: We allow RH2 by default because it is harmless. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
05d224468a
commit
0bcbc92629
@@ -362,10 +362,27 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
|
||||
struct inet6_skb_parm *opt = IP6CB(skb);
|
||||
struct in6_addr *addr = NULL;
|
||||
struct in6_addr daddr;
|
||||
struct inet6_dev *idev;
|
||||
int n, i;
|
||||
|
||||
struct ipv6_rt_hdr *hdr;
|
||||
struct rt0_hdr *rthdr;
|
||||
int accept_source_route = ipv6_devconf.accept_source_route;
|
||||
|
||||
if (accept_source_route < 0 ||
|
||||
((idev = in6_dev_get(skb->dev)) == NULL)) {
|
||||
kfree_skb(skb);
|
||||
return -1;
|
||||
}
|
||||
if (idev->cnf.accept_source_route < 0) {
|
||||
in6_dev_put(idev);
|
||||
kfree_skb(skb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (accept_source_route > idev->cnf.accept_source_route)
|
||||
accept_source_route = idev->cnf.accept_source_route;
|
||||
|
||||
in6_dev_put(idev);
|
||||
|
||||
if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
|
||||
!pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
|
||||
@@ -377,6 +394,22 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
|
||||
|
||||
hdr = (struct ipv6_rt_hdr *) skb->h.raw;
|
||||
|
||||
switch (hdr->type) {
|
||||
#ifdef CONFIG_IPV6_MIP6
|
||||
break;
|
||||
#endif
|
||||
case IPV6_SRCRT_TYPE_0:
|
||||
if (accept_source_route <= 0)
|
||||
break;
|
||||
kfree_skb(skb);
|
||||
return -1;
|
||||
default:
|
||||
IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
||||
IPSTATS_MIB_INHDRERRORS);
|
||||
icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) ||
|
||||
skb->pkt_type != PACKET_HOST) {
|
||||
IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
||||
@@ -434,11 +467,6 @@ looped_back:
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
||||
IPSTATS_MIB_INHDRERRORS);
|
||||
icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user