From: Antonio Quartulli Date: Sun, 26 Aug 2012 21:25:59 +0000 (+0200) Subject: batman-adv: check for more space before accessing the skb X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b8fcfa42e4ec5d55d4cccd5c728415e8bca0539d;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git batman-adv: check for more space before accessing the skb In batadv_check_unicast_ttvn() the code accesses both the unicast header and the Ethernet header in the payload. For this reason pskb_may_pull() must be invoked to check for the required space. Signed-off-by: Antonio Quartulli --- diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 456a0a9f8831..46dd5b47ed29 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -908,8 +908,12 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, bool tt_poss_change; int is_old_ttvn; - /* I could need to modify it */ - if (skb_cow(skb, sizeof(struct batadv_unicast_packet)) < 0) + /* check if there is enough data before accessing it */ + if (pskb_may_pull(skb, sizeof(*unicast_packet) + ETH_HLEN) < 0) + return 0; + + /* create a copy of the skb (in case of for re-routing) to modify it. */ + if (skb_cow(skb, sizeof(*unicast_packet)) < 0) return 0; unicast_packet = (struct batadv_unicast_packet *)skb->data;