]> err.no Git - linux-2.6/blobdiff - net/ipv6/esp6.c
Selecting LGUEST should turn on Guest support, as in 2.6.23.
[linux-2.6] / net / ipv6 / esp6.c
index 72a659806cadfb4f7d026e10e6eef9df41f9e0ef..44405325467626a5ca473ef647872ec8cdb14753 100644 (file)
@@ -29,7 +29,7 @@
 #include <net/ip.h>
 #include <net/xfrm.h>
 #include <net/esp.h>
-#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
 #include <linux/crypto.h>
 #include <linux/kernel.h>
 #include <linux/pfkeyv2.h>
@@ -109,7 +109,11 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
                        if (!sg)
                                goto unlock;
                }
-               skb_to_sgvec(skb, sg, esph->enc_data+esp->conf.ivlen-skb->data, clen);
+               sg_init_table(sg, nfrags);
+               skb_to_sgvec(skb, sg,
+                            esph->enc_data +
+                            esp->conf.ivlen -
+                            skb->data, clen);
                err = crypto_blkcipher_encrypt(&desc, sg, sg, clen);
                if (unlikely(sg != &esp->sgbuf[0]))
                        kfree(sg);
@@ -205,7 +209,10 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
                                goto out;
                        }
                }
-               skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen);
+               sg_init_table(sg, nfrags);
+               skb_to_sgvec(skb, sg,
+                            sizeof(*esph) + esp->conf.ivlen,
+                            elen);
                ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
                if (unlikely(sg != &esp->sgbuf[0]))
                        kfree(sg);
@@ -223,6 +230,12 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
                }
                /* ... check padding bits here. Silly. :-) */
 
+               /* RFC4303: Drop dummy packets without any error */
+               if (nexthdr[1] == IPPROTO_NONE) {
+                       ret = -EINVAL;
+                       goto out;
+               }
+
                pskb_trim(skb, skb->len - alen - padlen - 2);
                ret = nexthdr[1];
        }