netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ip_route_input panic fix
@ 2006-04-18  0:12 Stephen Hemminger
  2006-04-18  2:28 ` Herbert Xu
  2006-04-18  6:54 ` Herbert Xu
  0 siblings, 2 replies; 14+ messages in thread
From: Stephen Hemminger @ 2006-04-18  0:12 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

This fixes http://bugzilla.kernel.org/show_bug.cgi?id=6388
The bug is caused by ip_route_input dereferencing skb->nh.protocol of
the dummy skb passed dow from inet_rtm_getroute (Thanks Thomas for seeing
it). It only happens if the route requested is for a multicast IP
address.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

--- linux-2.6.16.6.orig/net/ipv4/route.c
+++ linux-2.6.16.6/net/ipv4/route.c
@@ -2750,7 +2750,10 @@ int inet_rtm_getroute(struct sk_buff *in
 	/* Reserve room for dummy headers, this skb can pass
 	   through good chunk of routing engine.
 	 */
-	skb->mac.raw = skb->data;
+	skb->mac.raw = skb->nh.raw = skb->data;
+
+	/* Bugfix: need to give ip_route_input enough of an IP header to not gag. */
+	skb->nh.iph->protocol = IPPROTO_ICMP;
 	skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
 
 	if (rta[RTA_SRC - 1])

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH] ip_route_input panic fix
@ 2006-04-19  0:59 Alexey Kuznetsov
  0 siblings, 0 replies; 14+ messages in thread
From: Alexey Kuznetsov @ 2006-04-19  0:59 UTC (permalink / raw)
  To: herbert, shemminger, davem, netdev

Hello!

> There is also the ARP code which passes an ARP packet through that
> would get dereferenced as an IP packet.  Granted this shouldn't crash
> because nh is set properly.

And point to something which is not an IP header. So, iph->protocol
is something funny. :-)

It is plain luck that this never happens, ARP packets
with multicast addresses are filtered out.

Mess, I agree.


> But we really should make up our mind as to whether the routing key
> comes from the arguments to ip_route_input (src/dst/...) or the skb.
>
> Using both is just asking for trouble.

Well, both sets are present only for use the same function in ARP.

So, arguments. skb can be even preserved, but it should not be used
for anything but debugging or for hints, when we should not create
cache entry.


BTW, I cannot figure out what ip_check_mc tries to do with protocol
(which is __u16 by some reason). If it creates cache entry, protocol
is not checked. Funny.

Alexey

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH] ip_route_input panic fix
@ 2006-04-19  1:00 Alexey Kuznetsov
  0 siblings, 0 replies; 14+ messages in thread
From: Alexey Kuznetsov @ 2006-04-19  1:00 UTC (permalink / raw)
  To: herbert, shemminger, davem, netdev

Hello!

> There is also the ARP code which passes an ARP packet through that
> would get dereferenced as an IP packet.  Granted this shouldn't crash
> because nh is set properly.

And points to something which is not an IP header. So, iph->protocol
is something funny. :-)

It is plain luck that this never happens, ARP packets
with multicast addresses are filtered out.

Mess, I agree.


> But we really should make up our mind as to whether the routing key
> comes from the arguments to ip_route_input (src/dst/...) or the skb.
>
> Using both is just asking for trouble.

Well, both sets are present only for use the same function in ARP.

So, arguments. Actually, skb can be preserved, but it should not be used
for anything but debugging or for hints, when we should not create
cache entry.


BTW, I cannot figure out what ip_check_mc() tries to do with protocol
(which is __u16 by some reason). If it creates cache entry, protocol
is not checked. Funny.

Alexey

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

end of thread, other threads:[~2006-04-19  9:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-18  0:12 [PATCH] ip_route_input panic fix Stephen Hemminger
2006-04-18  2:28 ` Herbert Xu
2006-04-18  2:49   ` Stephen Hemminger
2006-04-18  2:54     ` Herbert Xu
2006-04-18  5:45   ` David S. Miller
2006-04-18  6:54 ` Herbert Xu
2006-04-18 21:54   ` David S. Miller
2006-04-18 22:08     ` Herbert Xu
2006-04-18 23:52   ` Alexey Kuznetsov
2006-04-19  0:17     ` Herbert Xu
2006-04-19  3:53     ` David S. Miller
2006-04-19  9:46       ` Alexey Kuznetsov
  -- strict thread matches above, loose matches on Subject: below --
2006-04-19  0:59 Alexey Kuznetsov
2006-04-19  1:00 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).