]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[ESP]: Ensure IV is in linear part of the skb to avoid BUG() due to OOB access
authorThomas Graf <tgraf@suug.ch>
Thu, 27 Mar 2008 23:08:03 +0000 (16:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Mar 2008 23:08:03 +0000 (16:08 -0700)
ESP does not account for the IV size when calling pskb_may_pull() to
ensure everything it accesses directly is within the linear part of a
potential fragment. This results in a BUG() being triggered when the
both the IPv4 and IPv6 ESP stack is fed with an skb where the first
fragment ends between the end of the esp header and the end of the IV.

This bug was found by Dirk Nehring <dnehring@gmx.net> .

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/esp4.c
net/ipv6/esp6.c

index f3ceca31aa45c15e361f3d8557d4a5c13f726905..4e73e5708e700d276ddb3be80a9452931621a15b 100644 (file)
@@ -336,7 +336,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
        struct scatterlist *asg;
        int err = -EINVAL;
 
-       if (!pskb_may_pull(skb, sizeof(*esph)))
+       if (!pskb_may_pull(skb, sizeof(*esph) + crypto_aead_ivsize(aead)))
                goto out;
 
        if (elen <= 0)
index 0ec1402320ea63898bd9761b6bb243cab14dad12..c6bb4c6d24b38352b4430e7892b59068714a9b3e 100644 (file)
@@ -282,7 +282,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
        struct scatterlist *sg;
        struct scatterlist *asg;
 
-       if (!pskb_may_pull(skb, sizeof(*esph))) {
+       if (!pskb_may_pull(skb, sizeof(*esph) + crypto_aead_ivsize(aead))) {
                ret = -EINVAL;
                goto out;
        }