nuttx/sched/signal
Justin Hammond 27ff1e74e1 sched/signal: Unblock sigtimedwait through kernel memory.
nxsig_timedwait parked a pointer to the caller's siginfo buffer in the
TCB, for whoever eventually posts the signal to fill in.  But the
poster fills it in from its own context (another task, a kernel
thread, an interrupt), and in a kernel build the caller's buffer is
an address in the caller's private address space, which the poster
does not share.  The write lands wherever the currently active
mappings put it: the waiter wakes to find garbage where the signal
number should be, and some other process is left with a corrupted
page.  Flat builds share one address space, which is why this never
showed there.

Park the stack local in the TCB instead.  That is kernel memory,
mapped in every context, and it is copied out to the caller's buffer
after waking, in the caller's own context, exactly where the
pending-signal path already does the same thing.

Found on the EIC7700X port by an RTC alarm: the alarm signal, posted
from the low-priority work queue, woke a sigwaitinfo caller into an
assertion on the unblocking signal number while the init process,
whose address space had received the stray write, died of a jump to
address zero.  With this change the same test arms, waits and wakes
cleanly, repeatedly.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-08 14:59:21 -03:00
..
CMakeLists.txt arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
Make.defs arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_action.c sched/signal: use spinlock to protect signal queues 2026-01-17 18:29:17 -03:00
sig_allocpendingsigaction.c sched/signal: Move dynamic allocation of pending signals to a safe place 2025-05-08 21:32:08 +08:00
sig_cleanup.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_clockwait.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_default.c signal: add default sigaction for SIGURG 2026-01-13 13:56:39 -08:00
sig_deliver.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_dispatch.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_findaction.c sched: remove all spin_lock_irqsave(NULL) 2025-01-06 23:11:44 +08:00
sig_initialize.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_kill.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_lowest.c sched/signal: Fix nxsig_ismember() return value behavior 2025-11-25 10:02:52 +08:00
sig_nanosleep.c sleep: optimize sleep logic, to reduce the disable IRQ time 2024-10-09 13:54:29 +08:00
sig_notification.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_pause.c sched/signal: Remove shadow definitions to reduce unnecessary API 2025-10-14 17:40:18 +08:00
sig_pending.c sched/signal: use spinlock to protect signal queues 2026-01-17 18:29:17 -03:00
sig_ppoll.c usleep: use div_const to optimize the usleep 2024-09-12 18:14:39 +08:00
sig_procmask.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_pselect.c usleep: use div_const to optimize the usleep 2024-09-12 18:14:39 +08:00
sig_queue.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_releasependingsigaction.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
sig_releasependingsignal.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_removependingsignal.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_sleep.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
sig_suspend.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sig_tgkill.c arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sig_timedwait.c sched/signal: Unblock sigtimedwait through kernel memory. 2026-08-08 14:59:21 -03:00
sig_unmaskpendingsignal.c Fix signal delivered to a wrong thread 2025-05-08 21:32:35 +08:00
sig_usleep.c usleep: use div_const to optimize the usleep 2024-09-12 18:14:39 +08:00
sig_waitinfo.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
signal.h arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00