public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: check for more space before accessing the skb
@ 2012-08-26 21:25 Antonio Quartulli
  2012-09-02  8:42 ` Marek Lindner
  0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2012-08-26 21:25 UTC (permalink / raw)
  To: b.a.t.m.a.n

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>
---
 routing.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/routing.c b/routing.c
index 784e9cc..44109cc 100644
--- a/routing.c
+++ b/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;
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: check for more space before accessing the skb
  2012-08-26 21:25 [B.A.T.M.A.N.] [PATCH] batman-adv: check for more space before accessing the skb Antonio Quartulli
@ 2012-09-02  8:42 ` Marek Lindner
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2012-09-02  8:42 UTC (permalink / raw)
  To: b.a.t.m.a.n

On Monday, August 27, 2012 05:25:59 Antonio Quartulli wrote:
> 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>
> ---
>  routing.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Applied in revision 94494a1.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-02  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-26 21:25 [B.A.T.M.A.N.] [PATCH] batman-adv: check for more space before accessing the skb Antonio Quartulli
2012-09-02  8:42 ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox