Commit 64a5d9db authored by Jan Kiszka's avatar Jan Kiszka

cobalt/posix/signal: Fix iteration over sigwaiters

Using thread both as the iteration variable and the source of the list
causes list_for_each_entry to derail after the first thread that has no
hit. This could be triggered by sending a process a signal that was in
sigwait, but not for that signal.

Fix this by using a stable list pointer.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent c4459247
......@@ -45,6 +45,7 @@ static int cobalt_signal_deliver(struct cobalt_thread *thread,
{ /* nklocked, IRQs off */
struct cobalt_sigwait_context *swc;
struct xnthread_wait_context *wc;
struct list_head *sigwaiters;
int sig, ret;
sig = sigp->si.si_signo;
......@@ -66,10 +67,11 @@ static int cobalt_signal_deliver(struct cobalt_thread *thread,
* group, try to deliver to any thread from the same process
* waiting for that signal.
if (!group || list_empty(&thread->process->sigwaiters))
sigwaiters = &thread->process->sigwaiters;
if (!group || list_empty(sigwaiters))
return 0;
list_for_each_entry(thread, &thread->process->sigwaiters, signext) {
list_for_each_entry(thread, sigwaiters, signext) {
wc = xnthread_get_wait_context(&thread->threadbase);
swc = container_of(wc, struct cobalt_sigwait_context, wc);
if (sigismember(swc->set, sig))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment