There are many races with signals in linux user: - Multiple host signals in quick succession, fixed by keeping host signals blocked, and checking if target signals are blocked before calling target signal handler. - Signal shortly before blocking system call, fixed by either: - Block hosts signals, check and use host system call with sigset_t parameter. - Or check if signals are pending immediately before host system call and if a signal arrives between the check and system call rewind host instruction pointer to before the check. Also fixes SA_RESTART. - Signal before or during sensitive system call, fixed in a similar manner. - Close host and synchronous signals, partly fixed by implementing a separate queue for synchronous signals which are dispatched first. The asynchronous signal may still be delayed or lost rather than dispatched to another thread or handled after exec().
Also fixed: - Errno array bounds. - Default fatal actions occurring in the middle of target instructions. I have major problems testing the system call restarting: - x86, ARM MIPS, PowerPC and SPARC sucessful tested. - Microblaze and SH4 works without signals, but signal test case crashes with or without my changes. - Alpha works without signals, but don't have a toolchain. to compile the signal test case. - I have been unable to test UniCore32, OpenRISC, M68K, S390 and CRIS due to a lack of binaries and toolchains. Help would be appreciated - this is the only change I intend to make to unshared code to all targets. Outstanding issues: - The remaining blocking target system calls. - Fatal default actions may be delayed in a broken blocking target system call. Timothy E Baldwin (34): linux-user: Fix array bounds in errno conversion linux-user: Reindent signal handling linux-user: Support for restarting system calls linux-user: Support for restarting system calls for x86 targets linux-user: Support for restarting system calls for ARM targets linux-user: Support for restarting system calls for MIPS targets linux-user: Support for restarting system calls for PPC targets linux-user: Support for restarting system calls for SPARC targets linux-user: Test for restarting system calls linux-user: Support for restarting system calls for Microblaze targets linux-user: Support for restarting system calls for SH4 targets linux-user: Support for restarting system calls for APLHA targets linux-user: Fix signal before blocking system calls race and SA_RESTART linux-user: Use safe_syscall for read and write system calls linux-user: Remove redundant get_errno() calls linux-user: Use safe_syscall for open and openat system calls linux-user: Use safe_syscall for wait system calls linux-user: Fix race between multiple signals linux-user: Restart fork() if signals pending linux-user: Remove redundant default action check in queue_signal() linux-user: Remove redundant gdb_queuesig() linux-user: Remove real-time signal queuing linux-user: Queue synchronous signals separately linux-user: Restart execve() if signal pending linux-user: Restart exit() if signal pending linux-user: Restart kill() if signal pending linux-user: pause() should not pause if signal pending linux-user: Restart sigaction() if signal pending linux-user: Support for restarting system calls for UniCore32 targets linux-user: Support for restarting system calls for OpenRISC targets linux-user: Support for restarting system calls for M68K targets linux-user: Support for restarting system calls for S390 targets linux-user: Support for restarting system calls for CRIS targets linux-user: Remove TARGET_USE_ERESTARTSYS configure | 13 + gdbstub.c | 13 - include/exec/gdbstub.h | 1 - linux-user/Makefile.objs | 3 +- linux-user/errno_defs.h | 3 + linux-user/main.c | 210 ++-- linux-user/mips/syscall.h | 4 - linux-user/mips64/syscall.h | 4 - linux-user/ppc/syscall.h | 2 - linux-user/qemu.h | 37 +- linux-user/safe_syscall/x86_64.S | 34 + linux-user/signal.c | 2012 +++++++++++++++++++------------------- linux-user/syscall.c | 247 ++++- 13 files changed, 1422 insertions(+), 1161 deletions(-) create mode 100644 linux-user/safe_syscall/x86_64.S -- 2.1.4