Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8fcfa42 authored by Antonio Quartulli's avatar Antonio Quartulli
Browse files

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: default avatarAntonio Quartulli <ordex@autistici.org>
parent 60c39c75
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -908,8 +908,12 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
	bool tt_poss_change;
	bool tt_poss_change;
	int is_old_ttvn;
	int is_old_ttvn;


	/* I could need to modify it */
	/* check if there is enough data before accessing it */
	if (skb_cow(skb, sizeof(struct batadv_unicast_packet)) < 0)
	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;
		return 0;


	unicast_packet = (struct batadv_unicast_packet *)skb->data;
	unicast_packet = (struct batadv_unicast_packet *)skb->data;