netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ip multicast route bug fix
@ 2006-07-19 21:57 Stephen Hemminger
  2006-07-25  5:29 ` James Morris
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Stephen Hemminger @ 2006-07-19 21:57 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

This should fix the problem reported in http://bugzilla.kernel.org/show_bug.cgi?id=6186
where the skb is used after freed. The code in IP multicast route.

Code was reusing an skb which could lead to use after free or double free.

Signed-off-by: Stephen Hemminger <shemminger@dxpl.pdx.osdl.net>
---
 net/ipv4/ipmr.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index ba33f86..d336104 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1580,6 +1580,7 @@ int ipmr_get_route(struct sk_buff *skb, 
 	cache = ipmr_cache_find(rt->rt_src, rt->rt_dst);
 
 	if (cache==NULL) {
+		struct sk_buff *iskb;
 		struct net_device *dev;
 		int vif;
 
@@ -1593,12 +1594,19 @@ int ipmr_get_route(struct sk_buff *skb, 
 			read_unlock(&mrt_lock);
 			return -ENODEV;
 		}
-		skb->nh.raw = skb_push(skb, sizeof(struct iphdr));
-		skb->nh.iph->ihl = sizeof(struct iphdr)>>2;
-		skb->nh.iph->saddr = rt->rt_src;
-		skb->nh.iph->daddr = rt->rt_dst;
-		skb->nh.iph->version = 0;
-		err = ipmr_cache_unresolved(vif, skb);
+		
+		iskb = alloc_skb(sizeof(struct iphdr), GFP_KERNEL);
+		if (!iskb) {
+			read_unlock(&mrt_lock);
+			return -ENOMEM;
+		}
+		memset(iskb->data, 0, sizeof(struct iphdr));
+		iskb->nh.raw = iskb->data;
+		iskb->nh.iph->ihl = sizeof(struct iphdr)>>2;
+		iskb->nh.iph->saddr = rt->rt_src;
+		iskb->nh.iph->daddr = rt->rt_dst;
+
+		err = ipmr_cache_unresolved(vif, iskb);
 		read_unlock(&mrt_lock);
 		return err;
 	}
-- 
1.4.0


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

end of thread, other threads:[~2006-07-26 13:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-19 21:57 [PATCH] ip multicast route bug fix Stephen Hemminger
2006-07-25  5:29 ` James Morris
2006-07-25  6:03 ` Martin Josefsson
2006-07-25  8:03 ` Herbert Xu
2006-07-25 15:42   ` [PATCH] ip multicast route bug fix (rev2) Stephen Hemminger
2006-07-25 16:20 ` [PATCH] ip multicast route bug fix Alexey Kuznetsov
2006-07-25 15:55   ` Stephen Hemminger
2006-07-25 16:48     ` Alexey Kuznetsov
2006-07-25 18:31     ` Alexey Kuznetsov
2006-07-25 21:17     ` Alexey Kuznetsov
2006-07-25 21:24       ` Stephen Hemminger
2006-07-25 23:45       ` David Miller
2006-07-26  2:26       ` Herbert Xu
2006-07-26 13:27         ` Alexey Kuznetsov

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).