qemu/linux-user/sparc
Peter Maydell c0e370474b linux-user/sparc: Take pending signals in sparc64_set_context()
Every callsite of block_signals() checks its return value, except
the one in sparc64_set_context(). Generally you need to check,
because the standard pattern is:

    if (block_signals()) {
        return -QEMU_ERESTARTSYS;
    }
    /* do some blocking syscall */

and we need to take any pending signal before we do the blocking
operation, not afterwards.

The use in sparc64_set_context() doesn't do this.  It doesn't have to
because the operations it is doing aren't blocking, so it won't get
into "we didn't take the signal that we should have" races that
blocking syscalls do.  But it does make this way of updating the
signal mask inconsistent with how we do it in do_sigprocmask().
do_sigprocmask() does the usual "return -QEMU_ERESTARTSYS", so a
pending signal that was not blocked by the old signal mask and which
will be blocked by the new mask we're about to install will be taken
before we change the mask.  sparc64_set_context() doesn't check the
return value, so we won't take that pending signal.  That's not
wrong, because it just means the signal lost the race with the
executing code.  But it seems clearer to behave the same way as
do_sigprocmask(), not differently.

Make sparc64_set_context() check the return value of block_signals()
and return early if there's a pending signal to take.  We don't need
to return a separate return code to indicate this because the main
loop handles it the same either way.

Coverity CID: 1660058

Fixes: e0f0ce88eb ("linux-user/sparc: call block_signals() before set_sigmask() in setcontext")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
2026-07-18 23:47:33 +02:00
..
cpu_loop.c linux-user/sparc: Take pending signals in sparc64_set_context() 2026-07-18 23:47:33 +02:00
cpu_loop.h linux-user/sparc: flush register windows before core dump 2026-06-10 18:42:59 +02:00
elfload.c linux-user/sparc: flush register windows before core dump 2026-06-10 18:42:59 +02:00
meson.build meson: linux-user 2020-08-21 06:30:38 -04:00
signal.c linux-user/sparc: Take pending signals in sparc64_set_context() 2026-07-18 23:47:33 +02:00
sockbits.h linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW 2026-04-25 00:38:32 +02:00
syscall.tbl target/ppc: Fix lxvx/stxvx facility check 2024-09-27 10:32:29 +01:00
syscallhdr.sh license: Update deprecated SPDX tag GPL-2.0 to GPL-2.0-only 2024-09-20 10:11:59 +03:00
target_cpu.h target/sparc: Split psr and xcc into components 2023-11-05 11:53:13 -08:00
target_elf.h linux-user/sparc: flush register windows before core dump 2026-06-10 18:42:59 +02:00
target_errno_defs.h linux-user: Extract target errno to 'target_errno_defs.h' 2021-07-12 21:53:35 +02:00
target_fcntl.h linux-user: move sparc/sparc64 fcntl definitions to sparc/target_fcntl.h 2018-06-04 01:30:44 +02:00
target_mman.h linux-user: Define ELF_ET_DYN_BASE in $guest/target_mman.h 2023-08-08 13:27:15 -07:00
target_prctl.h linux-user: Split out do_prctl and subroutines 2022-01-06 11:40:52 +01:00
target_proc.h linux-user: Add missing /proc/cpuinfo fields for sparc 2025-01-16 20:57:17 -08:00
target_ptrace.h linux-user/sparc: Create target_ptrace.h 2025-08-30 07:04:04 +10:00
target_resource.h linux-user: Move generic TARGET_RLIMIT* definitions to generic/target_resource.h 2022-02-01 08:01:38 +01:00
target_signal.h linux-user/sparc: Handle tag overflow traps 2023-03-10 20:45:47 +01:00
target_structs.h linux-user/sparc: Merge sparc64 target_structs.h 2021-05-15 21:43:23 +02:00
target_syscall.h linux-user/sparc: Create target_ptrace.h 2025-08-30 07:04:04 +10:00
termbits.h linux-user: Add missing termios baud rates 2026-01-23 20:40:15 +01:00