user-exec: handle synchronous signals from QEMU gracefully
commit02bed6bd5f45819f1557a4b04db300a72383ecdb
authorAlex Bennée <alex.bennee@linaro.org>
Mon, 20 Mar 2017 11:31:44 +0000 (20 11:31 +0000)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 28 Mar 2017 09:50:35 +0000 (28 10:50 +0100)
tree878016bb7d1d5aed3dba30f136eeca3cca8ccdd4
parentea2afcf5b6727a577cf561fd8fe0d8c397ecc927
user-exec: handle synchronous signals from QEMU gracefully

When "tcg: enable thread-per-vCPU" (commit 3725794) 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 3725794 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: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
user-exec.c