Skip to content
Snippets Groups Projects
  • Daniele Buono's avatar
    58ebc2c3
    coroutine: support SafeStack in ucontext backend · 58ebc2c3
    Daniele Buono authored
    
    LLVM's SafeStack instrumentation does not yet support programs that make
    use of the APIs in ucontext.h
    With the current implementation of coroutine-ucontext, the resulting
    binary is incorrect, with different coroutines sharing the same unsafe
    stack and producing undefined behavior at runtime.
    This fix allocates an additional unsafe stack area for each coroutine,
    and sets the new unsafe stack pointer before calling swapcontext() in
    qemu_coroutine_new.
    This is the only place where the pointer needs to be manually updated,
    since sigsetjmp/siglongjmp are already instrumented by LLVM to properly
    support SafeStack.
    The additional stack is then freed in qemu_coroutine_delete.
    
    Signed-off-by: default avatarDaniele Buono <dbuono@linux.vnet.ibm.com>
    Message-id: 20200529205122.714-2-dbuono@linux.vnet.ibm.com
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    58ebc2c3
    History
    coroutine: support SafeStack in ucontext backend
    Daniele Buono authored
    
    LLVM's SafeStack instrumentation does not yet support programs that make
    use of the APIs in ucontext.h
    With the current implementation of coroutine-ucontext, the resulting
    binary is incorrect, with different coroutines sharing the same unsafe
    stack and producing undefined behavior at runtime.
    This fix allocates an additional unsafe stack area for each coroutine,
    and sets the new unsafe stack pointer before calling swapcontext() in
    qemu_coroutine_new.
    This is the only place where the pointer needs to be manually updated,
    since sigsetjmp/siglongjmp are already instrumented by LLVM to properly
    support SafeStack.
    The additional stack is then freed in qemu_coroutine_delete.
    
    Signed-off-by: default avatarDaniele Buono <dbuono@linux.vnet.ibm.com>
    Message-id: 20200529205122.714-2-dbuono@linux.vnet.ibm.com
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>