Subject: Re: Kernel panic when using bridge

From: Bandan Das <[email-masked]>
Date: Tue, 12 Apr 2011 12:32:01 -0400

On  0, Eric Dumazet <[email-masked]> wrote:
> Le mardi 12 avril 2011 à 17:13 +0200, Jan Lübbe a écrit :
> > On Tue, 2011-04-12 at 16:49 +0200, Eric Dumazet wrote: 
> > > Of course, this might be a complete shot in the dark, but a
> > > stackprotector fault in icmp_send() really sounds like a problem in
> > > ip_options_echo() [ or bad input data given to this function ]
> > 
> > It was my understanding that all IP options given to ip_options_echo are
> > either from local sources or have gone through ip_options_compile, which
> > seems to verify that the sum of the individual option lengths do not
> > exceed the ip header. So there wouldn't need to be additional checks in
> > ip_options_echo.
> > 
> > If this is not the case, we need size checks in ip_options_echo before
> > copying over each option.
> > 
> > > Other related changes (but as old as v2.6.22) :
> > > 
> > > commit 11a03f78fbf15a866ba
> > > ([NetLabel]: core network changes)
> > 
> > When investigating the problem I had with timestamps, i found that most
> > of the lines in ip_options_echo and _compile have not been changed since
> > before 2.2 (some even before 2.0). The newer changes have all been
> > updates for changed API elsewhere in the stack.
> > 
> 
> commit 462fb2af9788a82 might be the problem.
> (bridge : Sanitize skb before it enters the IP stack)
> 
> We are supposed to provide a zeroed ip_options to ip_options_compile()
> 
> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
> index 008ff6c..f3bc322 100644
> --- a/net/bridge/br_netfilter.c
> +++ b/net/bridge/br_netfilter.c
> @@ -249,11 +249,9 @@ static int br_parse_ip_options(struct sk_buff *skb)
>  		goto drop;
>  	}
>  
> -	/* Zero out the CB buffer if no options present */
> -	if (iph->ihl == 5) {
> -		memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
> +	memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
> +	if (iph->ihl == 5)
>  		return 0;
> -	}
>  
>  	opt->optlen = iph->ihl*4 - sizeof(struct iphdr);
>  	if (ip_options_compile(dev_net(dev), opt, skb))
> 
> 
Looks good to me. The CB area should be cleared out anyways before 
handing over the packet. Thank you for spotting this!

Acked-by: Bandan Das <[email-masked]>