• Alex Bennée's avatar
    user-exec: handle synchronous signals from QEMU gracefully · 02bed6bd
    Alex Bennée authored
    When "tcg: enable thread-per-vCPU" (commit 37257942) was merged the
    lifetime of current_cpu was changed. Previously a broken linux-user
    call might abort() which can eventually escalate into a SIGSEGV which
    would then crash qemu as it attempted to deref a NULL current_cpu.
    After commit 37257942 it would attempt to fixup state and re-start the
    run-loop and much hilarity (i.e. a looping lockup) would ensue from
    jumping into a stale jmp_env.
    As we can actually tell if we are in the run-loop from looking at the
    cpu->running flag we should catch this badness first and abort()
    cleanly rather than try to soldier on. There is a theoretical race
    between the flag being set and sigsetjmp refreshing the jump buffer
    but we can try really hard to not introduce crashes into that code.
    [LV: setgroups03 fails on powerpc LTP]
    Reported-by: 's avatarLaurent Vivier <laurent@vivier.eu>
    Signed-off-by: 's avatarAlex Bennée <alex.bennee@linaro.org>
    Reviewed-by: 's avatarRichard Henderson <rth@twiddle.net>
    Reviewed-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
user-exec.c 18.2 KB