Skip to contentSkip to conversation

user: recursive signal delivery fix and test

PATCH In review Nicholas Piggin 3 participants 13 messages Mar 21 – Mar 31

lore
Share & tools
lore
#0 lore raw

cover user: recursive signal delivery fix and test

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

Thanks,
Nick

Nicholas Piggin (3):
linux-user: sigaltstack lock_user_struct missing unlock bsd-user, linux-user: signal: recursive signal delivery fix tests/tcg: add recursive signal delivery tests

 bsd-user/signal.c            |  10 +-
 linux-user/signal.c          |  36 +++---
 tests/tcg/multiarch/badsig.c | 226 +++++++++++++++++++++++++++++++++++
 3 files changed, 252 insertions(+), 20 deletions(-)
 create mode 100644 tests/tcg/multiarch/badsig.c
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/3 linux-user: sigaltstack lock_user_struct missing unlock

lock_user_struct is missing a corresponding unlock.

(bsd-user does correctly unlock in the equivalent code.)

---
 linux-user/signal.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
linux-user/signal.c +14 -13
index 804096bd44..e4b8b28bfe 100644
@@ -292,11 +292,10 @@ void target_save_altstack(target_stack_t *uss, CPUArchState *env)
     __put_user(ts->sigaltstack_used.ss_size, &uss->ss_size);
 }
 
-abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env)
+abi_long target_restore_altstack(target_stack_t *ss, CPUArchState *env)
 {
     TaskState *ts = get_task_state(thread_cpu);
     size_t minstacksize = TARGET_MINSIGSTKSZ;
-    target_stack_t ss;
 
 #if defined(TARGET_PPC64)
     /* ELF V2 for PPC64 has a 4K minimum stack size for signal handlers */
@@ -306,33 +305,29 @@ abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env)
     }
 #endif
 
-    __get_user(ss.ss_sp, &uss->ss_sp);
-    __get_user(ss.ss_size, &uss->ss_size);
-    __get_user(ss.ss_flags, &uss->ss_flags);
-
     if (on_sig_stack(get_sp_from_cpustate(env))) {
         return -TARGET_EPERM;
     }
 
-    switch (ss.ss_flags) {
+    switch (ss->ss_flags) {
     default:
         return -TARGET_EINVAL;
 
     case TARGET_SS_DISABLE:
-        ss.ss_size = 0;
-        ss.ss_sp = 0;
+        ss->ss_sp = 0;
+        ss->ss_size = 0;
         break;
 
     case TARGET_SS_ONSTACK:
     case 0:
-        if (ss.ss_size < minstacksize) {
+        if (ss->ss_size < minstacksize) {
             return -TARGET_ENOMEM;
         }
         break;
     }
 
-    ts->sigaltstack_used.ss_sp = ss.ss_sp;
-    ts->sigaltstack_used.ss_size = ss.ss_size;
+    ts->sigaltstack_used.ss_sp = ss->ss_sp;
+    ts->sigaltstack_used.ss_size = ss->ss_size;
     return 0;
 }
 
@@ -1140,11 +1135,17 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
 
     if (uss_addr) {
         target_stack_t *uss;
+        target_stack_t ss;
 
         if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) {
             goto out;
         }
-        ret = target_restore_altstack(uss, env);
+        __get_user(ss.ss_sp, &uss->ss_sp);
+        __get_user(ss.ss_size, &uss->ss_size);
+        __get_user(ss.ss_flags, &uss->ss_flags);
+        unlock_user_struct(uss, uss_addr, 0);
+
+        ret = target_restore_altstack(&ss, env);
         if (ret) {
             goto out;
         }
Signature · 1 line
2.51.0
#6 lore raw

PATCH 3/3 tests/tcg: add recursive signal delivery tests

In reply to Nicholas Piggin

Add tests which exercise a synchronous signal being raised in synchronous and asynchronous signal delivery paths. It does this by delivering them with an altstack that is made inaccessible, then catching the badframe SIGSEGV with a handler on the regular stack.

---
 tests/tcg/multiarch/badsig.c | 226 +++++++++++++++++++++++++++++++++++
 1 file changed, 226 insertions(+)
 create mode 100644 tests/tcg/multiarch/badsig.c
tests/tcg/multiarch/badsig.c new file +226 -0
new file mode 100644
index 0000000000..0f346f4147
@@ -0,0 +1,226 @@
+/*
+ * linux-user "badframe" signal handling tests.
+ *
+ * Copyright (c) 2026 Tenstorrent USA, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Test "badframe" signal handling paths, which force a
+ * SIGSEGV signal from the signal handler setup code,
+ * which tests the recursive signal "restart_scan" logic
+ * in process_pending_signals().
+ */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <string.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+
+#undef DEBUG
+#ifdef DEBUG
+#define dprintf(...) printf(__VA_ARGS__)
+#else
+#define dprintf(...)
+#endif
+
+static void error1(const char *filename, int line, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    fprintf(stderr, "%s:%d: ", filename, line);
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, "\n");
+    va_end(ap);
+    exit(1);
+}
+
+static int __chk_error(const char *filename, int line, int ret)
+{
+    if (ret < 0) {
+        error1(filename, line, "%m (ret=%d, errno=%d/%s)",
+               ret, errno, strerror(errno));
+    }
+    return ret;
+}
+
+#define error(fmt, ...) error1(__FILE__, __LINE__, fmt, ## __VA_ARGS__)
+
+#define chk_error(ret) __chk_error(__FILE__, __LINE__, (ret))
+
+static bool do_siglongjmp;
+static sigjmp_buf current_sigjmp_buf;
+
+static volatile int total_alarm_count;
+
+static void sig_alarm(int sig, siginfo_t *info, void *puc)
+{
+    if (sig != SIGRTMIN) {
+        error("unexpected signal");
+    }
+    dprintf("SIGRTMIN\n");
+    total_alarm_count++;
+}
+
+static volatile int total_segv_count;
+
+static void sig_segv(int sig, siginfo_t *info, void *puc)
+{
+    if (sig != SIGSEGV) {
+        error("unexpected signal");
+    }
+    dprintf("SIGSEGV\n");
+    total_segv_count++;
+    if (do_siglongjmp) {
+        dprintf("siglongjmp()\n");
+        siglongjmp(current_sigjmp_buf, 1);
+    }
+}
+
+static volatile int total_trap_count;
+
+static void sig_trap(int sig, siginfo_t *info, void *puc)
+{
+    if (sig == SIGTRAP) {
+        dprintf("SIGTRAP\n");
+    } else if (sig == SIGILL) {
+        dprintf("SIGILL\n");
+    } else if (sig == SIGABRT) {
+        dprintf("SIGABRT\n");
+    } else {
+        error("unexpected signal");
+    }
+    total_trap_count++;
+    if (do_siglongjmp) {
+        dprintf("siglongjmp()\n");
+        siglongjmp(current_sigjmp_buf, 1);
+    }
+}
+
+static void test_signals(void)
+{
+    struct sigaction act;
+    struct itimerspec it;
+    timer_t tid;
+    struct sigevent sev;
+    stack_t ss;
+    void *mem;
+
+    /* Set up SEGV handler */
+    act.sa_sigaction = sig_segv;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_SIGINFO;
+    chk_error(sigaction(SIGSEGV, &act, NULL));
+
+    /* Set up an altstack */
+    mem = mmap(NULL, SIGSTKSZ, PROT_READ | PROT_WRITE,
+               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+    if (mem == MAP_FAILED) {
+            fprintf(stderr, "out of memory");
+            exit(EXIT_FAILURE);
+    }
+
+    ss.ss_sp = mem;
+    ss.ss_flags = 0;
+    ss.ss_size = SIGSTKSZ;
+    chk_error(sigaltstack(&ss, NULL));
+
+    /* Async signal test */
+
+    /* Set up RTMIN handler on alt stack */
+    act.sa_sigaction = sig_alarm;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_SIGINFO | SA_ONSTACK;
+    chk_error(sigaction(SIGRTMIN, &act, NULL));
+
+    /* Create POSIX timer */
+    sev.sigev_notify = SIGEV_SIGNAL;
+    sev.sigev_signo = SIGRTMIN;
+    sev.sigev_value.sival_ptr = &tid;
+    chk_error(timer_create(CLOCK_REALTIME, &sev, &tid));
+
+    it.it_interval.tv_sec = 0;
+    it.it_interval.tv_nsec = 1000000;
+    it.it_value.tv_sec = 0;
+    it.it_value.tv_nsec = 1000000;
+    chk_error(timer_settime(tid, 0, &it, NULL));
+
+    while (total_alarm_count == 0) {
+        usleep(1000);
+    }
+    total_alarm_count = 0;
+
+    chk_error(timer_delete(tid));
+
+    assert(total_segv_count == 0);
+
+    /* Make the alt stack bad */
+    chk_error(mprotect(mem, SIGSTKSZ, PROT_NONE));
+
+    chk_error(timer_create(CLOCK_REALTIME, &sev, &tid));
+    chk_error(timer_settime(tid, 0, &it, NULL));
+
+    while (total_segv_count == 0) {
+        usleep(1000);
+    }
+    total_segv_count = 0;
+
+    chk_error(timer_delete(tid));
+
+    assert(total_alarm_count == 0);
+
+    /* Make the alt stack good */
+    chk_error(mprotect(mem, SIGSTKSZ, PROT_READ | PROT_WRITE));
+
+    /* Bad sync signal test */
+
+    /* Set up SIGILL/TRAP/ABRT handler on alt stack */
+    act.sa_sigaction = sig_trap;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_SIGINFO | SA_ONSTACK;
+    chk_error(sigaction(SIGTRAP, &act, NULL));
+    chk_error(sigaction(SIGILL, &act, NULL));
+    chk_error(sigaction(SIGABRT, &act, NULL));
+
+    if (sigsetjmp(current_sigjmp_buf, 1) == 0) {
+        do_siglongjmp = true;
+        /* Cause a synchronous signal */
+        dprintf("__builtin_trap()\n");
+        __builtin_trap();
+        assert(0);
+    }
+    do_siglongjmp = false;
+    assert(total_trap_count == 1);
+    total_trap_count = 0;
+    assert(total_segv_count == 0);
+
+    /* Make the alt stack bad */
+    chk_error(mprotect(mem, SIGSTKSZ, PROT_NONE));
+
+    if (sigsetjmp(current_sigjmp_buf, 1) == 0) {
+        do_siglongjmp = true;
+        /* Cause a synchronous signal */
+        dprintf("__builtin_trap()\n");
+        __builtin_trap();
+        assert(0);
+    }
+    do_siglongjmp = false;
+    assert(total_segv_count == 1);
+    total_segv_count = 0;
+    assert(total_trap_count == 0);
+}
+
+int main(int argc, char **argv)
+{
+    test_signals();
+    return 0;
+}
Signature · 1 line
2.51.0
#3 lore raw

PATCH 2/3 bsd-user, linux-user: signal: recursive signal delivery fix

In reply to Nicholas Piggin

Synchronous signals must accommodate a synchronous signal being raised during delivery, as asynchronous ones do. For example badframe errors during delivery will cause SIGSEGV to be raised.

Without this fix, cpu_loop() runs process_pending_signals() which delivers the first synchronous signal (e.g., SIGILL) which fails to set the handler and forces SIGSEGV, but that is not picked up. process_pending_signals() returns. Then cpu_loop() runs cpu_exec() again, which attempts to execute the same instruction, another SIGILL.

---
 bsd-user/signal.c   | 10 ++++++----
 linux-user/signal.c |  9 ++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)
bsd-user/signal.c +6 -4
index dadcc037dc..3e5e41e1b1 100644
@@ -998,7 +998,12 @@ void process_pending_signals(CPUArchState *env)
                 sigdelset(&ts->signal_mask, target_to_host_signal(sig));
                 sigact_table[sig - 1]._sa_handler = TARGET_SIG_DFL;
             }
+            /*
+             * Restart scan from the beginning, as handle_pending_signal
+             * might have resulted in a new synchronous signal (eg SIGSEGV).
+             */
             handle_pending_signal(env, sig, &ts->sync_signal);
+            goto restart_scan;
         }
 
         k = ts->sigtab;
@@ -1008,10 +1013,7 @@ void process_pending_signals(CPUArchState *env)
             if (k->pending &&
                 !sigismember(blocked_set, target_to_host_signal(sig))) {
                 handle_pending_signal(env, sig, k);
-                /*
-                 * Restart scan from the beginning, as handle_pending_signal
-                 * might have resulted in a new synchronous signal (eg SIGSEGV).
-                 */
+                /* Restart scan, explained above. */
                 goto restart_scan;
             }
         }
linux-user/signal.c +6 -3
index e4b8b28bfe..9d43e080ce 100644
@@ -1385,6 +1385,11 @@ void process_pending_signals(CPUArchState *cpu_env)
             }
 
             handle_pending_signal(cpu_env, sig, &ts->sync_signal);
+            /*
+             * Restart scan from the beginning, as handle_pending_signal
+             * might have resulted in a new synchronous signal (eg SIGSEGV).
+             */
+            goto restart_scan;
         }
 
         for (sig = 1; sig <= TARGET_NSIG; sig++) {
@@ -1395,9 +1400,7 @@ void process_pending_signals(CPUArchState *cpu_env)
                 (!sigismember(blocked_set,
                               target_to_host_signal_table[sig]))) {
                 handle_pending_signal(cpu_env, sig, &ts->sigtab[sig - 1]);
-                /* Restart scan from the beginning, as handle_pending_signal
-                 * might have resulted in a new synchronous signal (eg SIGSEGV).
-                 */
+                /* Restart scan, explained above. */
                 goto restart_scan;
             }
         }
Signature · 1 line
2.51.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] bsd-user, linux-user: signal: recursive signal delivery fix

Quoted 11 lines · Nicholas Piggin

Synchronous signals must accommodate a synchronous signal being raised during delivery, as asynchronous ones do. For example badframe errors during delivery will cause SIGSEGV to be raised.

Without this fix, cpu_loop() runs process_pending_signals() which delivers the first synchronous signal (e.g., SIGILL) which fails to set the handler and forces SIGSEGV, but that is not picked up. process_pending_signals() returns. Then cpu_loop() runs cpu_exec() again, which attempts to execute the same instruction, another SIGILL.

Quoted 6 lines
---
 bsd-user/signal.c   | 10 ++++++----
 linux-user/signal.c |  9 ++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

Interesting edge case...

Warner

Quoted 66 lines
bsd-user/signal.c +3 -0
index dadcc037dc..3e5e41e1b1 100644
@@ -998,7 +998,12 @@ void process_pending_signals(CPUArchState *env)
                 sigdelset(&ts->signal_mask, target_to_host_signal(sig));
                 sigact_table[sig - 1]._sa_handler = TARGET_SIG_DFL;
             }
+            /*
+             * Restart scan from the beginning, as handle_pending_signal
+             * might have resulted in a new synchronous signal (eg

SIGSEGV).

bsd-user/signal.c +2 -2
+             */
             handle_pending_signal(env, sig, &ts->sync_signal);
+            goto restart_scan;
         }
 
         k = ts->sigtab;
@@ -1008,10 +1013,7 @@ void process_pending_signals(CPUArchState *env)
             if (k->pending &&
                 !sigismember(blocked_set, target_to_host_signal(sig))) {
                 handle_pending_signal(env, sig, k);
-                /*
-                 * Restart scan from the beginning, as

handle_pending_signal
- * might have resulted in a new synchronous signal (eg
SIGSEGV).

bsd-user/signal.c +1 -1
-                 */
+                /* Restart scan, explained above. */
                 goto restart_scan;
             }
         }
linux-user/signal.c +3 -0
index e4b8b28bfe..9d43e080ce 100644
@@ -1385,6 +1385,11 @@ void process_pending_signals(CPUArchState *cpu_env)
             }
 
             handle_pending_signal(cpu_env, sig, &ts->sync_signal);
+            /*
+             * Restart scan from the beginning, as handle_pending_signal
+             * might have resulted in a new synchronous signal (eg

SIGSEGV).

linux-user/signal.c +2 -1
+             */
+            goto restart_scan;
         }
 
         for (sig = 1; sig <= TARGET_NSIG; sig++) {
@@ -1395,9 +1400,7 @@ void process_pending_signals(CPUArchState *cpu_env)
                 (!sigismember(blocked_set,
                               target_to_host_signal_table[sig]))) {
                 handle_pending_signal(cpu_env, sig, &ts->sigtab[sig - 1]);
-                /* Restart scan from the beginning, as

handle_pending_signal
- * might have resulted in a new synchronous signal (eg
SIGSEGV).

linux-user/signal.c +1 -2
-                 */
+                /* Restart scan, explained above. */
                 goto restart_scan;
             }
         }
--

2.51.0

#2 lore raw

Re: [PATCH 1/3] linux-user: sigaltstack lock_user_struct missing unlock

In reply to Nicholas Piggin
Quoted 15 lines · Nicholas Piggin

lock_user_struct is missing a corresponding unlock.

(bsd-user does correctly unlock in the equivalent code.)

---

linux-user/signal.c +1 -0
@@ -1140,11 +1135,17 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr,
 
     if (uss_addr) {
         target_stack_t *uss;
+        target_stack_t ss;
 

linux-user/signal.c abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, · line 1148

Quoted 10 lines
linux-user/signal.c +6 -1
         if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) {
             goto out;
         }
-        ret = target_restore_altstack(uss, env);
+        __get_user(ss.ss_sp, &uss->ss_sp);
+        __get_user(ss.ss_size, &uss->ss_size);
+        __get_user(ss.ss_flags, &uss->ss_flags);
+        unlock_user_struct(uss, uss_addr, 0);
+
+        ret = target_restore_altstack(&ss, env);

Why do we need to change to copying the entries out of the stack here? Does something not work if we do the unlock_user_struct() after the call to target_restore_sigaltstack() ?

linux-user/signal.c abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, · line 1151

Quoted 3 lines
linux-user/signal.c +0 -0
         if (ret) {
             goto out;
         }

thanks
-- PMM

Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] bsd-user, linux-user: signal: recursive signal delivery fix

In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

Synchronous signals must accommodate a synchronous signal being raised during delivery, as asynchronous ones do. For example badframe errors during delivery will cause SIGSEGV to be raised.

Quoted 8 lines

Without this fix, cpu_loop() runs process_pending_signals() which delivers the first synchronous signal (e.g., SIGILL) which fails to set the handler and forces SIGSEGV, but that is not picked up. process_pending_signals() returns. Then cpu_loop() runs cpu_exec() again, which attempts to execute the same instruction, another SIGILL.

thanks
-- PMM

Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] tests/tcg: add recursive signal delivery tests

In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

Add tests which exercise a synchronous signal being raised in synchronous and asynchronous signal delivery paths. It does this by delivering them with an altstack that is made inaccessible, then catching the badframe SIGSEGV with a handler on the regular stack.

The other thing it would be interesting to test is:
if the stack is inaccessible and we generate a SIGSEGV to the *same* stack because we don't have an altstack set up, do we do the right thing (i.e. terminate the process by switching to the default-handling for SIGSEGV) rather than e.g. looping forever failing to deliver it. But that would be more of a pain to test -- I think you would need to fork a child and do that in the child so the parent could check for the right wait status from it, or something.

Some testing of this edge case is better than none, so I'm not asking you to write that extra test.

Quoted 7 lines
---
 tests/tcg/multiarch/badsig.c | 226 +++++++++++++++++++++++++++++++++++
 1 file changed, 226 insertions(+)
 create mode 100644 tests/tcg/multiarch/badsig.c

+static int __chk_error(const char *filename, int line, int ret)

Function names shouldn't start with __.

Otherwise

thanks
-- PMM

#8 lore raw
In reply to Nicholas Piggin
Quoted 8 lines · Nicholas Piggin

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

I think 8bd3773cce1 is fixing "we try to deliver a non-synchronous signal, and in the process of delivery we got a signal", whereas this patchset is the rather similar "while delivering a synchronous signal we got another signal". I think you're right that the only signal we can actually get during handle_pending_signal() in practice is the SIGSEGV.

-- PMM

#9 lore raw
In reply to Nicholas Piggin
Quoted 9 lines · Nicholas Piggin

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

Quoted 7 lines

Thanks,
Nick

Nicholas Piggin (3):
linux-user: sigaltstack lock_user_struct missing unlock bsd-user, linux-user: signal: recursive signal delivery fix tests/tcg: add recursive signal delivery tests

I'm going to take patches 2 and 3 into a pullreq I'm doing for linux-user fixes for rc2, so we can get the fix into 11.0. (I've made a s/__chk_error/do_chk_error/ adjustment to patch 3.)

Patch 1 I had a review comment on and in any case it is only a problem if you build with CONFIG_DEBUG_REMAP, so if that drifts out to 11.1 that's fine.

thanks
-- PMM

#10 lore raw
Quoted 14 lines · Peter Maydell
Quoted 12 lines · Nicholas Piggin

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

Thanks,
Nick

Quoted 8 lines
Quoted 4 lines

Nicholas Piggin (3):
linux-user: sigaltstack lock_user_struct missing unlock bsd-user, linux-user: signal: recursive signal delivery fix tests/tcg: add recursive signal delivery tests

I'm going to take patches 2 and 3 into a pullreq I'm doing for linux-user fixes for rc2, so we can get the fix into 11.0. (I've made a s/__chk_error/do_chk_error/ adjustment to patch 3.)

Patch 3 also has a missing "#include <stdbool.h>" in the test program; otherwise it fails to compile in 'make check-tcg'.

-- PMM

#11 lore raw
Quoted 21 lines · Peter Maydell
Quoted 19 lines · Peter Maydell
Quoted 16 lines · Nicholas Piggin

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

Thanks,
Nick

Nicholas Piggin (3):
linux-user: sigaltstack lock_user_struct missing unlock bsd-user, linux-user: signal: recursive signal delivery fix tests/tcg: add recursive signal delivery tests

Quoted 6 lines
Quoted 3 lines

I'm going to take patches 2 and 3 into a pullreq I'm doing for linux-user fixes for rc2, so we can get the fix into 11.0. (I've made a s/__chk_error/do_chk_error/ adjustment to patch 3.)

Patch 3 also has a missing "#include <stdbool.h>" in the test program; otherwise it fails to compile in 'make check-tcg'.

...and also my mail client somehow ate this other part I meant to say:

I had to suppress the running of the test for hexagon, hppa, microblaze and sh4, because it fails there. My guess is this is bugs in the signal frame handling on those targets, though for hppa it might be related to the upward-growing stack.

tests/tcg/multiarch/Makefile.target +0 -0
@@ -229,5 +229,11 @@ MULTIARCH_TESTS := $(filter-out

test-plugin-set-pc, $(MULTIARCH_TESTS))
test-plugin-syscall-filter: CFLAGS+=-DSKIP
endif

+# Don't build the badsig test on these targets for now, as it fails +# (probably bugs in the signal handling for those archs) +ifeq ($(filter hexagon-% hppa-% microblaze-% sh4-%,$(TARGET)),$(TARGET)) +MULTIARCH_TESTS := $(filter-out badsig, $(MULTIARCH_TESTS)) +endif
+
# Update TESTS
TESTS += $(MULTIARCH_TESTS)

-- PMM

#12 lore raw
Quoted 30 lines · Peter Maydell
Quoted 21 lines · Peter Maydell
Quoted 19 lines · Peter Maydell
Quoted 16 lines · Nicholas Piggin

I found this recursive delivery problem when testing new riscv vector state support patches (plus a minor lock user balance bug).

This or similar type of issue was fixed with 8bd3773cce1 but I couldn't see exactly what scenario that was addressing. Is there any other way a signal can be generated during handle_pending_signal()? The SIGTTIN case, perhaps?

Thanks,
Nick

Nicholas Piggin (3):
linux-user: sigaltstack lock_user_struct missing unlock bsd-user, linux-user: signal: recursive signal delivery fix tests/tcg: add recursive signal delivery tests

Quoted 6 lines
Quoted 3 lines

I'm going to take patches 2 and 3 into a pullreq I'm doing for linux-user fixes for rc2, so we can get the fix into 11.0. (I've made a s/__chk_error/do_chk_error/ adjustment to patch 3.)

Patch 3 also has a missing "#include <stdbool.h>" in the test program; otherwise it fails to compile in 'make check-tcg'.

Quoted 6 lines

...and also my mail client somehow ate this other part I meant to say:

I had to suppress the running of the test for hexagon, hppa, microblaze and sh4, because it fails there. My guess is this is bugs in the signal frame handling on those targets, though for hppa it might be related to the upward-growing stack.

PPC failed too. I'm dropping the test-case patch, I don't have more time to spend trying to flush out the other targets it doesn't work on right now...

-- PMM