Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 371561 - dev-libs/openssl causes large amounts of Unaligned Accesses on alpha
Summary: dev-libs/openssl causes large amounts of Unaligned Accesses on alpha
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Blocks: unaligned-access
  Show dependency tree
Reported: 2011-06-14 07:52 UTC by Tobias Klausmann
Modified: 2011-08-12 19:37 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Klausmann gentoo-dev 2011-06-14 07:52:21 UTC
nrpe(30187): unaligned trap at 000002000011ab94: 00000001200401ec 2d 31
Comment 1 Sergei Trofimovich gentoo-dev 2011-08-11 10:43:36 UTC
I've played a bit with nrpe and have come to conclusion it's an openssl itself who issues unaligned access (SSL_accept).
Comment 2 Sergei Trofimovich gentoo-dev 2011-08-11 18:24:59 UTC
It's an openssl's alpha specific 'OPENSSL_cleanse' function (openssl-1.0.0d/crypto/

Dump of assembler code for function OPENSSL_cleanse:
   0x0000020000120d3c <+0>:     beq     a1,0x20000120da4 <OPENSSL_cleanse+104>
   0x0000020000120d40 <+4>:     and     a0,0x7,v0
   0x0000020000120d44 <+8>:     andnot  a1,0x7,at
   0x0000020000120d48 <+12>:    beq     at,0x20000120d50 <OPENSSL_cleanse+20>
   0x0000020000120d4c <+16>:    beq     v0,0x20000120d84 <OPENSSL_cleanse+72>
   0x0000020000120d50 <+20>:    ldq_u   t0,0(a0)
   0x0000020000120d54 <+24>:    mov     a0,t1
   0x0000020000120d58 <+28>:    mskbl   t0,a0,t0
   0x0000020000120d5c <+32>:    lda     a0,1(a0)
   0x0000020000120d60 <+36>:    subq    a1,0x1,a1
   0x0000020000120d64 <+40>:    subq    v0,0x1,v0
   0x0000020000120d68 <+44>:    beq     a1,0x20000120d70 <OPENSSL_cleanse+52>
   0x0000020000120d6c <+48>:    bne     v0,0x20000120d58 <OPENSSL_cleanse+28>
   0x0000020000120d70 <+52>:    stq_u   t0,0(t1)
   0x0000020000120d74 <+56>:    beq     a1,0x20000120da4 <OPENSSL_cleanse+104>
   0x0000020000120d78 <+60>:    andnot  a1,0x7,at
   0x0000020000120d7c <+64>:    mov     a1,v0
   0x0000020000120d80 <+68>:    beq     at,0x20000120d50 <OPENSSL_cleanse+20>
=> 0x0000020000120d84 <+72>:    stq     zero,0(a0)
   0x0000020000120d88 <+76>:    subq    a1,0x8,a1
   0x0000020000120d8c <+80>:    lda     a0,8(a0)
   0x0000020000120d90 <+84>:    andnot  a1,0x7,at
   0x0000020000120d94 <+88>:    bne     at,0x20000120d84 <OPENSSL_cleanse+72>
   0x0000020000120d98 <+92>:    beq     a1,0x20000120da4 <OPENSSL_cleanse+104>
   0x0000020000120d9c <+96>:    mov     a1,v0
   0x0000020000120da0 <+100>:   br      0x20000120d50 <OPENSSL_cleanse+20>
   0x0000020000120da4 <+104>:   ret
Comment 3 Sergei Trofimovich gentoo-dev 2011-08-11 18:55:15 UTC
Minimal reproducer:

// gcc cleanse_test.c -o ct -lcrypto
#include <openssl/crypto.h>

int main(void)
    char buffer [128];
    int off;
    int sz;

    for (off = 0; off < sizeof (buffer); ++off)
        for (sz = 0; sz < sizeof (buffer) - off; ++sz)
            OPENSSL_cleanse (buffer + off, sz);

    return 0;
Comment 4 Sergei Trofimovich gentoo-dev 2011-08-12 13:10:27 UTC
And we get the fix from upstream!

Tested on my extended testcase. It fixes not only misalignment,
but also memsets _every_ byte to zero.

OPENSSL_cleanse did miss some trailing bytes before that patch, so it has security flavour :]

Reassigning to base-system.
Comment 5 Sergei Trofimovich gentoo-dev 2011-08-12 19:37:18 UTC
Pushed as:

>  12 Aug 2011; Sergei Trofimovich <> openssl-1.0.0d.ebuild,
>  +files/openssl-1.0.0d-alpha-fix-unalign.patch:
>  Fix unaligned access on alpha (bug #371561 by Tobias Klausmann). Thanks to
>  Andy Polyakov <> for the fix.

Thanks for the report, Tobias!