Subject: Re: alignment crash in v6 ipfilter when receiving on gif
To: Chris Ross <cross+netbsd@distal.com>
From: Martin Husemann <martin@duskware.de>
List: port-sparc64
Date: 07/10/2007 15:45:57
On Tue, Jul 10, 2007 at 08:58:46AM -0400, Chris Ross wrote:

> >			if (IP6_NEQ(&fin->fin_fi.fi_dst,
> >				    (i6addr_t *)&ip6->ip6_src))
> >				fin->fin_flx |= FI_BAD;
[..]
> 
> http://marc.info/?l=ipfilter&m=118110355014240&w=2
> 
>   I don't know that it was ever concluded what the problem was, but  
> Darren (and I) thought it sounded like an erroneous optimization by  
> the compiler, rather than an error in the code.

To me it looks like a bug in the code:

	&ip6->ip6_src is known to be 32bit aligned

but

	i6addr_t needs 64bit alignment.

This kind of casts allow the compiler to assume proper alignment of the
casted pointer, and thus to use 64bit loads.

The memcpy() suggest in the refered thread is the correct fix.

Martin