summaryrefslogtreecommitdiff
path: root/cipher/pubkey.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-10-02 20:47:56 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-10-10 15:51:09 +0300
commit150c0313f971bcea62d2802f0389c883e11ebb31 (patch)
tree098296cd6558d7096aea7ad4f8f45c1f1545fafa /cipher/pubkey.c
parent94b652ecb006c29fa2ffb1badc9f02b758581737 (diff)
downloadlibgcrypt-150c0313f971bcea62d2802f0389c883e11ebb31.tar.gz
Prevent tail call optimization with _gcry_burn_stack
* configure.ac: New check, HAVE_GCC_ASM_VOLATILE_MEMORY. * src/g10lib.h (_gcry_burn_stack): Rename to __gcry_burn_stack. (__gcry_burn_stack_dummy): New. (_gcry_burn_stack): New macro. * src/misc.c (_gcry_burn_stack): Rename to __gcry_burn_stack. (__gcry_burn_stack_dummy): New. -- Tail call optimization can turn _gcry_burn_stack call in to tail jump. When this happens, stack pointer is restored to initial state of current function. This causes problem for _gcry_burn_stack because its callers do not count in current function stack depth. One solution is to prevent gcry_burn_stack being tail optimized by inserting dummy function call behind it. Another would be to add memory barrier 'asm volatile("":::"memory")' behind every _gcry_burn_stack call. This however requires GCC asm support from compiler. Patch adds detection for memory barrier support and when available uses memory barrier to prevent when tail call optimization. If not available dummy function call is used instead. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/pubkey.c')
0 files changed, 0 insertions, 0 deletions