netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH net-2.6] bridge: fix br_multicast_ipv6_rcv for paged skbs
@ 2010-12-30 23:06 Stephen Hemminger
       [not found] ` <9mk4bme8o97ir27xi8a9fbsd.1293750376929-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
  2010-12-31 20:45 ` David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Stephen Hemminger @ 2010-12-30 23:06 UTC (permalink / raw)
  To: Winkler, Tomas, Stephen Hemminger, Johannes Berg
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org ,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org 

Although copy is slower for large packets, this is a non performance path. The code in question is for bridged multicast Ipv6 ICMP packets. This case is so uncritical it could be done in BASIC and no one could possibly care!

"Winkler, Tomas" <tomas.winkler@intel.com> wrote:

>
>
>> -----Original Message-----
>> From: Stephen Hemminger [mailto:shemminger@vyatta.com]
>> Sent: Thursday, December 30, 2010 9:06 PM
>> To: Johannes Berg
>> Cc: Winkler, Tomas; davem@davemloft.net; netdev@vger.kernel.org; linux-
>> wireless@vger.kernel.org
>> Subject: Re: [PATCH net-2.6] bridge: fix br_multicast_ipv6_rcv for paged
>> skbs
>> 
>> On Thu, 30 Dec 2010 19:52:14 +0100
>> Johannes Berg <johannes@sipsolutions.net> wrote:
>> 
>> > On Thu, 2010-12-30 at 10:46 -0800, Stephen Hemminger wrote:
>> >
>> > > This doesn't look correct. The calculation of the offset doesn't look
>> correct.
>> > > Just following the skb_clone(), the skb_pull value is "offset".
>> > > Also, the other checks return -EINVAL for incorrectly formed packet.
>> > >
>> > > --- a/net/bridge/br_multicast.c	2010-12-30 10:29:58.579510488 -0800
>> > > +++ b/net/bridge/br_multicast.c	2010-12-30 10:43:27.273386691 -0800
>> > > @@ -1464,6 +1464,9 @@ static int br_multicast_ipv6_rcv(struct
>> > >  	if (offset < 0 || nexthdr != IPPROTO_ICMPV6)
>> > >  		return 0;
>> > >
>> > > +	if (!pskb_may_pull(skb, offset))
>> > > +		return -EINVAL;
>> > > +
>> > >  	/* Okay, we found ICMPv6 header */
>> > >  	skb2 = skb_clone(skb, GFP_ATOMIC);
>> > >  	if (!skb2)
>> >
>> > Wouldn't that make more sense after the clone anyway? But if you look at
>> > my email, you'll find that there's potentially, and conditionally, more
>> > stuff that will be read from the skb's header, which hasn't necessarily
>> > been pulled in, so I think this still won't fix all the issues.
>> >
>> > Seeing how this only affects some ICMPv6 packets, maybe we should just
>> > use skb_copy() instead?
>> 
>> It comes out cleaner, and the check can be simplified.
>> 
>> --- a/net/bridge/br_multicast.c	2010-12-30 10:47:12.031733855 -0800
>> +++ b/net/bridge/br_multicast.c	2010-12-30 11:00:12.135801266 -0800
>> @@ -1465,19 +1465,19 @@ static int br_multicast_ipv6_rcv(struct
>>  		return 0;
>> 
>>  	/* Okay, we found ICMPv6 header */
>> -	skb2 = skb_clone(skb, GFP_ATOMIC);
>> +	skb2 = skb_copy(skb, GFP_ATOMIC);
>>  	if (!skb2)
>>  		return -ENOMEM;
>> 
>> +	err = -EINVAL;
>> +	if (skb2->len < offset + sizeof(*icmp6h))
>> +		goto out;
>> +
>>  	len -= offset - skb_network_offset(skb2);
>> 
>>  	__skb_pull(skb2, offset);
>>  	skb_reset_transport_header(skb2);
>> 
>> -	err = -EINVAL;
>> -	if (!pskb_may_pull(skb2, sizeof(*icmp6h)))
>> -		goto out;
>> -
>>  	icmp6h = icmp6_hdr(skb2);
>> 
>>  	switch (icmp6h->icmp6_type) {
>> 
>>
>Sorry for dump question but isn't there performance penalty on using skb_copy vs. skb_clone?
>
>Anyhow Below is a code snippet from ip6_input.c so you probably would want to fix it all over. 
>BTW offset and the pointer arithmetic really gives the same number +1, I'm not surly why the original author would thought it be safer than just using offset.
>
>					offset = ipv6_skip_exthdr(skb, sizeof(*hdr),
>                                                          &nexthdr);
>                                if (offset < 0)
>                                        goto out;
> 
>                                if (nexthdr != IPPROTO_ICMPV6)
>                                        goto out;
> 
>                                if (!pskb_may_pull(skb, (skb_network_header(skb) +
>                                                   offset + 1 - skb->data)))
>                                        goto out;
> 
>                                icmp6 = (struct icmp6hdr *)(skb_network_header(skb) + offset);
>
>
>
>Thanks
>Tomas
>
>
>---------------------------------------------------------------------
>Intel Israel (74) Limited
>
>This e-mail and any attachments may contain confidential material for
>the sole use of the intended recipient(s). Any review or distribution
>by others is strictly prohibited. If you are not the intended
>recipient, please contact the sender and delete all copies.
>

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: BUG: while bridging Ethernet and wireless device:
@ 2010-12-29 16:12 Tomas Winkler
  2010-12-30 11:32 ` [PATCH net-2.6] bridge: fix br_multicast_ipv6_rcv for paged skbs Tomas Winkler
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Winkler @ 2010-12-29 16:12 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-netdev, linux-wireless,
	YOSHIFUJI Hideaki / 吉藤英明

2010/12/29 Johannes Berg <johannes@sipsolutions.net>:
> On Thu, 2010-12-16 at 14:11 +0200, Tomas Winkler wrote:
>> Will be happy if someone can give me some more insight. (kernel 2.6.37-rc5)
>
> Tomas looked into it a bit more and told me that it happens on IPv6
> packets. To recap, he gets
>
> kernel BUG at include/linux/skbuff.h:1178!
> with
> EIP: [<f83edd65>] br_multicast_rcv+0xc95/0xe1c [bridge]
>
> Also remember that the packets are almost fully nonlinear, when they get
> here they likely have almost no data in the skb header.
>
> I then looked at br_multicast_ipv6_rcv(), and it looks fishy:
>
> Up to:
>        skb2 = skb_clone(skb, GFP_ATOMIC);
>
> everything's fine, since ipv6_skip_exthdr() will use
> skb_header_pointer(). At this point, offset is the result of
> ipv6_skip_exthdr(). Remember that skb_clone() is not skb_copy().

So far I can confirm that switching to sbk_copy fixes the crash.

Thanks
Tomas

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

end of thread, other threads:[~2010-12-31 21:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-30 23:06 [PATCH net-2.6] bridge: fix br_multicast_ipv6_rcv for paged skbs Stephen Hemminger
     [not found] ` <9mk4bme8o97ir27xi8a9fbsd.1293750376929-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2010-12-30 23:29   ` Winkler, Tomas
     [not found]     ` <6F5C1D715B2DA5498A628E6B9C124F04019BF36ABD-KS4eWWg9cz+vNW/NfzhIbrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-12-31 10:18       ` Johannes Berg
2010-12-31 20:45 ` David Miller
2010-12-31 21:16   ` Winkler, Tomas
  -- strict thread matches above, loose matches on Subject: below --
2010-12-29 16:12 BUG: while bridging Ethernet and wireless device: Tomas Winkler
2010-12-30 11:32 ` [PATCH net-2.6] bridge: fix br_multicast_ipv6_rcv for paged skbs Tomas Winkler
2010-12-30 18:46   ` Stephen Hemminger
2010-12-30 18:52     ` Johannes Berg
     [not found]       ` <1293735134.21956.1.camel-8upI4CBIZJIJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2010-12-30 19:06         ` Stephen Hemminger
2010-12-30 21:00           ` Winkler, Tomas

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