netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Herbert Xu <herbert@gondor.apana.org.au>, davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH] ip multicast route bug fix (rev2)
Date: Tue, 25 Jul 2006 08:42:38 -0700	[thread overview]
Message-ID: <20060725084238.32bcc50f@localhost.localdomain> (raw)
In-Reply-To: <E1G5Ht7-00060p-00@gondolin.me.apana.org.au>

IP multicast route code was reusing an skb which causes
use after free and double free.

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

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index ba33f86..f5d3d96 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 *skb2;
 		struct net_device *dev;
 		int vif;
 
@@ -1593,12 +1594,21 @@ 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);
+		
+		skb2 = alloc_skb(sizeof(struct iphdr) + sizeof(struct nlmsghdr),
+				 GFP_ATOMIC);
+		if (!skb2) {
+			read_unlock(&mrt_lock);
+			return -ENOMEM;
+		}
+
+		memset(skb2->data, 0, sizeof(struct iphdr));
+		skb2->nh.raw = skb2->data;
+		skb2->nh.iph->ihl = sizeof(struct iphdr)>>2;
+		skb2->nh.iph->saddr = rt->rt_src;
+		skb2->nh.iph->daddr = rt->rt_dst;
+
+		err = ipmr_cache_unresolved(vif, skb2);
 		read_unlock(&mrt_lock);
 		return err;
 	}
-- 
1.4.0


  reply	other threads:[~2006-07-25 16:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Stephen Hemminger [this message]
2006-07-25 16:20 ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060725084238.32bcc50f@localhost.localdomain \
    --to=shemminger@osdl.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).