"make check" test-hash-method bus error (Sparc alignment)

Rainer Jung rainer.jung at kippdata.de
Tue Feb 6 22:26:47 EET 2018


Hi there,

when doing "make check" for a 2.3.0 build on Solaris Sparc I get a bus 
error due to an alignment issue.

It seems the error is only happening during testing, because in the 
official API it was fixed in

https://github.com/dovecot/core/commit/d8361cc8576d9ede93a037f9b96f2a3f9b7e9054#diff-2ff53ae0e00a90ee20d648229ad91d2b

But the tests use hand written test vectors, that are not correctly aligned:

...
hash method md4 (test vectors) ....................................... : ok
hash method md5 (test vectors) ....................................... : ok
/bin/ksh[2]: 24287 Bus Error(coredump)
make[4]: *** [Makefile:2655: check-local] Error 1

gdb output:

Program terminated with signal SIGBUS, Bus error.
#0  sha1_loop (ctxt=0xffbff724, input=0x83908, len=3) at sha1.c:224
224                     ctxt->c.b64[0] += copysiz * 8;

(gdb) print &ctxt->c.b64[0]
$1 = (uint64_t *) 0xffbff73c

So the address of the 8 byte type is not divisible by 8 (Sparc alignment 
requirement).

Full stack:

(gdb) bt full
#0  sha1_loop (ctxt=0xffbff724, input=0x83908, len=3) at sha1.c:224
         input_c = 0x83908 "abc"
         gaplen = <optimized out>
         gapstart = <optimized out>
         off = 0
         copysiz = 3
#1  0x00024eb0 in test_hash_methods_fips () at test-hash-method.c:338
         n = 0
         method = 0xc4e68 <hash_method_sha1>
         context = 0xffbff724 "gE#\001▒ͫ\211\230▒▒▒\020\062Tv▒▒▒▒"
         result = "▒9▒▒^kK\r2U▒▒\225`\030\220▒▒\a\t"
         i = 7
         last_method = 0x839d0 "sha1"
         test_vectors = {{method = 0x838e0 "md4", input = 0x838e8, ilen 
= 0, rounds = 1, output = 0x838f0, olen = 16}, {method = 0x838e0 "md4", 
input = 0x83908, ilen = 3,
             rounds = 1, output = 0x83910, olen = 16}, {method = 0x838e0 
"md4", input = 0x83928, ilen = 62, rounds = 1, output = 0x83968, olen = 
16}, {method = 0x83980 "md5",
             input = 0x838e8, ilen = 0, rounds = 1, output = 0x83988, 
olen = 16}, {method = 0x83980 "md5", input = 0x83908, ilen = 3, rounds = 
1, output = 0x839a0, olen = 16}, {
             method = 0x83980 "md5", input = 0x83928, ilen = 62, rounds 
= 1, output = 0x839b8, olen = 16}, {method = 0x839d0 "sha1", input = 
0x838e8, ilen = 0, rounds = 1,
             output = 0x839d8, olen = 20}, {method = 0x839d0 "sha1", 
input = 0x83908, ilen = 3, rounds = 1, output = 0x839f0, olen = 20}, 
{method = 0x839d0 "sha1",
             input = 0x83a08, ilen = 56, rounds = 1, output = 0x83a48, 
olen = 20}, {method = 0x83a60 "sha3-256", input = 0x838e8, ilen = 0, 
rounds = 1, output = 0x83a70,
             olen = 32}, {method = 0x83a60 "sha3-256", input = 0x83a98, 
ilen = 135, rounds = 1, output = 0x83b20, olen = 32}, {method = 0x83a60 
"sha3-256", input = 0x83b48,
             ilen = 200, rounds = 1, output = 0x83c18, olen = 32}, 
{method = 0x83a60 "sha3-256", input = 0x83c40, ilen = 1, rounds = 200, 
output = 0x83c18, olen = 32}, {
             method = 0x83c48 "sha3-512", input = 0x838e8, ilen = 0, 
rounds = 1, output = 0x83c58, olen = 64}, {method = 0x83c48 "sha3-512", 
input = 0x83a98, ilen = 135,
             rounds = 1, output = 0x83ca0, olen = 64}, {method = 0x83c48 
"sha3-512", input = 0x83b48, ilen = 200, rounds = 1, output = 0x83ce8, 
olen = 64}, {
             method = 0x83c48 "sha3-512", input = 0x83c40, ilen = 1, 
rounds = 200, output = 0x83ce8, olen = 64}}
#2  0x0003e3e0 in test_run_named_funcs (tests=tests at entry=0x80434 
<test_functions>, match=match at entry=0x7fd40 "") at test-common.c:255
         _data_stack_cur_id = 2
         i = <optimized out>
#3  0x0003f1e4 in test_run_named_with_fatals (match=0x7fd40 "", 
tests=0x80434 <test_functions>, fatals=0x7fde8 <fatal_functions>) at 
test-common.c:337
No locals.
#4  0x0001e024 in _start ()


Unaligned data comes from file src/lib/test-hash-method.c:


...
     53  static void test_hash_methods_fips() {
     54          const char *last_method = NULL;
     55
     56          struct {
     57                  const char *method;
     58                  const void *input;
     59                  size_t ilen;
     60                  size_t rounds;
     61                  const void *output;
     62                  size_t olen;
     63          } test_vectors[] =
     64          {
...
    115                  { "sha1",
    116                          "",
    117                          0,
    118                          1,
    119                          "\xda\x39\xa3\xee\x5e\x6b\x4b\x0d"
    120                          "\x32\x55\xbf\xef\x95\x60\x18\x90"
    121                          "\xaf\xd8\x07\x09",
    122                          160 / 8
    123                  },
...

etc.

The input data needs to be 8 byte aligned but is just a void *.

Thanks and regards,

Rainer


More information about the dovecot mailing list