]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[IPSEC]: Do not let packets pass when ICMP flag is off
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Dec 2007 02:54:16 +0000 (18:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:57:43 +0000 (14:57 -0800)
This fixes a logical error in ICMP policy checks which lets
packets through if the state ICMP flag is off.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/icmp.c
net/ipv6/icmp.c

index c41f3cc4fba83bc901f44b24b8e432ce2dba7880..ce5b4be559aa74fcc287405f7eb6e9417eec0977 100644 (file)
@@ -977,10 +977,13 @@ int icmp_rcv(struct sk_buff *skb)
        struct icmphdr *icmph;
        struct rtable *rt = (struct rtable *)skb->dst;
 
-       if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb) && skb->sp &&
-           skb->sp->xvec[skb->sp->len - 1]->props.flags & XFRM_STATE_ICMP) {
+       if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
                int nh;
 
+               if (!(skb->sp && skb->sp->xvec[skb->sp->len - 1]->props.flags &
+                                XFRM_STATE_ICMP))
+                       goto drop;
+
                if (!pskb_may_pull(skb, sizeof(*icmph) + sizeof(struct iphdr)))
                        goto drop;
 
index 1659d2fb01fee445eaeae74470cf3c98c56b51b5..c3bbd8687307368f232999b5b7b22afb4da7f8a4 100644 (file)
@@ -644,10 +644,13 @@ static int icmpv6_rcv(struct sk_buff *skb)
        struct icmp6hdr *hdr;
        int type;
 
-       if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb) && skb->sp &&
-           skb->sp->xvec[skb->sp->len - 1]->props.flags & XFRM_STATE_ICMP) {
+       if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
                int nh;
 
+               if (!(skb->sp && skb->sp->xvec[skb->sp->len - 1]->props.flags &
+                                XFRM_STATE_ICMP))
+                       goto drop_no_count;
+
                if (!pskb_may_pull(skb, sizeof(*hdr) + sizeof(*orig_hdr)))
                        goto drop_no_count;