From: Claus A. <sta...@es...> - 2013-12-18 04:29:29
|
It seems the stack alignment on AMD64 (BSD) is broken. My program crashes when linked with OpenSSL 1.0.1e due to a misaligned stack (see below). According to the AMD64 ABI %rsp must be congruent 8 modulo 16 on function entry. I'm attaching a hack to deal with this, but it needs to be reviewed and maybe fixed? It fixes my test program, but that's of course not sufficient as "proof" that this is correct. Breakpoint 5, sha1_block_data_order_ssse3 () at sha1-x86_64.s:1295 1295 pushq %rbx Current language: auto; currently asm (gdb) p $rsp $15 = (void *) 0x8007360a0 This is wrong and causes a crash here: 1328 movdqa %xmm0,0(%rsp) (gdb) n Program received signal SIGBUS, Bus error. sha1_block_data_order_ssse3 () at sha1-x86_64.s:1328 (gdb) where #0 sha1_block_data_order_ssse3 () at sha1-x86_64.s:1295 #1 0x000000000045bc68 in SHA1_Final (md=0x8007361d8 "Øu÷¸;¤¿Pqs\224½0sÜ¢·ñþ", c=0x800c39240) at md32_common.h:372 #2 0x0000000000487bb4 in final (ctx=0x8007361a8, md=0x8007361d8 "Øu÷¸;¤¿Pqs\224½0sÜ¢·ñþ") at m_sha1.c:81 #3 0x00000000004800ec in EVP_DigestFinal_ex (ctx=0x8007361a8, md=0x8007361d8 "Øu÷¸;¤¿Pqs\224½0sÜ¢·ñþ", size=0x0) at digest.c:272 #4 0x000000000050e089 in ssleay_rand_add (buf=0x8007362a0, num=8, add=0) at md_rand.c:289 #5 0x000000000047da97 in RAND_add (buf=0x8007362a0, num=8, entropy=0) at rand_lib.c:157 #6 0x000000000040de2b in ssl23_accept (s=0x800c49c00) at s23_srvr.c:155 #7 0x000000000041a384 in SSL_accept (s=0x800c49c00) at ssl_lib.c:940 #8 0x000000000040b2dd in do_tls_operation (fp=<value optimized out>, hsfunc=0x41a350 <SSL_accept>, rfunc=0, wfunc=0, buf=0x0, num=0, bytes=0x8007384a8) at ../../mta/libmta/tlsbio.c:218 #9 0x0000000000405394 in handle_session (srv_socket_index=<value optimized out>, cli_nfd=0x800c06ac0) at ../../../mta/statethreads/examples/smtps2.c:2904 #10 0x0000000000408c43 in handle_connections (arg=0x0) at ../../../mta/statethreads/examples/smtps2.c:1778 #11 0x000000000056e38f in _st_thread_main () at ../../mta/statethreads/sched.c:329 #12 0x000000000056e473 in st_thread_create (start=0x4089e0 <handle_connections>, arg=0x0, joinable=0, stk_size=<value optimized out>) at ../../mta/statethreads/sched.c:593 #13 0x0000000000000000 in ?? () |