b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge
@ 2011-02-05 21:41 Sven Eckelmann
  2011-02-06 23:24 ` Marek Lindner
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Eckelmann @ 2011-02-05 21:41 UTC (permalink / raw)
  To: b.a.t.m.a.n

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>
---
 batman-adv/unicast.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/batman-adv/unicast.c b/batman-adv/unicast.c
index 6a9ab61..04b152c 100644
--- a/batman-adv/unicast.c
+++ b/batman-adv/unicast.c
@@ -50,6 +50,11 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
 		skb = tfp->skb;
 	}
 
+	if (skb_linearize(skb) < 0 || skb_linearize(tmp_skb) < 0) {
+		kfree_skb(tfp->skb);
+		return NULL;
+	}
+
 	skb_pull(tmp_skb, sizeof(struct unicast_frag_packet));
 	if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) {
 		/* free buffered skb, skb will be freed later */
-- 
1.7.2.3


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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge
  2011-02-05 21:41 [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge Sven Eckelmann
@ 2011-02-06 23:24 ` Marek Lindner
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2011-02-06 23:24 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Saturday 05 February 2011 22:41:58 Sven Eckelmann wrote:
> 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.

Applied in revision 1933.

Thanks,
Marek

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

* [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge
  2011-02-07 23:59 [B.A.T.M.A.N.] pull request: batman-adv 2011-02-08 Sven Eckelmann
@ 2011-02-07 23:59 ` Sven Eckelmann
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2011-02-07 23:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, b.a.t.m.a.n, Marek Lindner

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>
---
 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 ee41fef..d1a6113 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,
 		skb = tfp->skb;
 	}
 
+	if (skb_linearize(skb) < 0 || skb_linearize(tmp_skb) < 0)
+		goto err;
+
 	skb_pull(tmp_skb, sizeof(struct unicast_frag_packet));
-	if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) {
-		/* free buffered skb, skb will be freed later */
-		kfree_skb(tfp->skb);
-		return NULL;
-	}
+	if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0)
+		goto err;
 
 	/* move free entry to end */
 	tfp->skb = NULL;
@@ -70,6 +70,11 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
 	unicast_packet->packet_type = BAT_UNICAST;
 
 	return skb;
+
+err:
+	/* free buffered skb, skb will be freed later */
+	kfree_skb(tfp->skb);
+	return NULL;
 }
 
 static void frag_create_entry(struct list_head *head, struct sk_buff *skb)
-- 
1.7.2.3


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

end of thread, other threads:[~2011-02-07 23:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-05 21:41 [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge Sven Eckelmann
2011-02-06 23:24 ` Marek Lindner
2011-02-07 23:59 [B.A.T.M.A.N.] pull request: batman-adv 2011-02-08 Sven Eckelmann
2011-02-07 23:59 ` [B.A.T.M.A.N.] [PATCH] batman-adv: Linearize fragment packets before merge Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).