sshd broken on arm?

Dag-Erling Smørgrav des at des.no
Fri Jan 25 04:54:49 PST 2008


Nicholas Clark <nick at ccl4.org> writes:
> On Fri, Jan 25, 2008 at 12:23:09PM +0100, Dag-Erling Smrgrav wrote:
> > None of this matters.  What John pointed out means that the code is
> > wrong and the compiler is right.  The code is not allowed to assume
> > that an object is correctly aligned unless it is of a type that
> > requires the correct alignment.  The easiest way to do this is with
> > a union, e.g.
> Whilst that is correct, why is the compiler changing the alignment of the
> struct for different optimiser settings but all other flags identical?

Because *it is not a struct*.

It is an array of char, and char has no special alignment requirement.

The bug is in the code, which uses pointer aliasing in a way that is
strictly speaking legal but which places responsibility for alignment
issues squarely in the code and not the compiler.

IIRC, this is precisely the same issue that we had in libalias when the
checksum recalculation broke because it was doing unaligned 16-bit
accesses (many years ago now, see twowords() in alias.c)

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-arm mailing list