Skip to content

Commit

Permalink
batman-adv: check for more space before accessing the skb
Browse files Browse the repository at this point in the history
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 <ordex@autistici.org>
  • Loading branch information
Antonio Quartulli committed Oct 29, 2012
1 parent 60c39c7 commit b8fcfa4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b8fcfa4

Please sign in to comment.