pppoe: Unshare skb before anything else
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 10 Jun 2008 21:08:25 +0000 (14:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Jun 2008 21:08:25 +0000 (14:08 -0700)
We need to unshare the skb first as otherwise pskb_may_pull may
write to a shared skb which could be bad.

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

index d89ccfd6650c48c50060829200677c6fa4d3cad5..bafb69b6f7cbdeb26ea7975a2d46d2f04f7bdb24 100644 (file)
@@ -432,12 +432,12 @@ static int pppoe_disc_rcv(struct sk_buff *skb,
        if (dev_net(dev) != &init_net)
                goto abort;
 
-       if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
-               goto abort;
-
        if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
                goto out;
 
+       if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
+               goto abort;
+
        ph = pppoe_hdr(skb);
        if (ph->code != PADT_CODE)
                goto abort;