diff options
author | Sven Eckelmann <sven@narfation.org> | 2011-02-06 18:26:43 -0500 |
---|---|---|
committer | Sven Eckelmann <sven@narfation.org> | 2011-02-07 18:54:31 -0500 |
commit | 531c9da8c854c5b075383253a57fdd4e0be82e99 (patch) | |
tree | ad3cd10621d05b18b1b403f28733e0bc11b8eb8f /net/batman-adv/unicast.c | |
parent | 1181e1daace88018b2ff66592aa10a4791d705ff (diff) |
batman-adv: Linearize fragment packets before merge
We access the data inside the skbs of two fragments directly using memmove
during the merge. The data of the skb could span over multiple skb pages. An
direct access without knowledge about the pages would lead to an invalid memory
access.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
[lindner_marek@yahoo.de: Move return from function to the end]
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/unicast.c')
-rw-r--r-- | net/batman-adv/unicast.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index ee41fef04b21..d1a611322549 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c | |||
@@ -50,12 +50,12 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, | |||
50 | skb = tfp->skb; | 50 | skb = tfp->skb; |
51 | } | 51 | } |
52 | 52 | ||
53 | if (skb_linearize(skb) < 0 || skb_linearize(tmp_skb) < 0) | ||
54 | goto err; | ||
55 | |||
53 | skb_pull(tmp_skb, sizeof(struct unicast_frag_packet)); | 56 | skb_pull(tmp_skb, sizeof(struct unicast_frag_packet)); |
54 | if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) { | 57 | if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) |
55 | /* free buffered skb, skb will be freed later */ | 58 | goto err; |
56 | kfree_skb(tfp->skb); | ||
57 | return NULL; | ||
58 | } | ||
59 | 59 | ||
60 | /* move free entry to end */ | 60 | /* move free entry to end */ |
61 | tfp->skb = NULL; | 61 | tfp->skb = NULL; |
@@ -70,6 +70,11 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, | |||
70 | unicast_packet->packet_type = BAT_UNICAST; | 70 | unicast_packet->packet_type = BAT_UNICAST; |
71 | 71 | ||
72 | return skb; | 72 | return skb; |
73 | |||
74 | err: | ||
75 | /* free buffered skb, skb will be freed later */ | ||
76 | kfree_skb(tfp->skb); | ||
77 | return NULL; | ||
73 | } | 78 | } |
74 | 79 | ||
75 | static void frag_create_entry(struct list_head *head, struct sk_buff *skb) | 80 | static void frag_create_entry(struct list_head *head, struct sk_buff *skb) |