This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ac1ebbf7b9aee1743fe811d8f1304e90526008f4 Author: zhangyuan29 <[email protected]> AuthorDate: Fri Nov 13 14:12:25 2026 +0800 signal: zero-initialize siginfo in kill() and tgkill() The siginfo_t sent by kill()/tgkill() is initialized field by field, leaving every field not explicitly assigned - most notably si_user - carrying stack garbage. Only the sigaction-queue path of nxsig_dispatch() assigns si_user; the pending-signal path memcpy's the struct as-is, so the garbage reaches a sigtimedwait()/sigwaitinfo() consumer unchanged. sig_queue() already documents the sender-side obligation ("Will be set in sig_dispatch.c") for this field; the kill paths simply miss it. Zero the structure first, then keep the existing field assignments. Signed-off-by: zhangyuan29 <[email protected]> --- sched/signal/sig_kill.c | 9 +++++++++ sched/signal/sig_tgkill.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/sched/signal/sig_kill.c b/sched/signal/sig_kill.c index 31af2fb405c..4e13d2d98ac 100644 --- a/sched/signal/sig_kill.c +++ b/sched/signal/sig_kill.c @@ -33,6 +33,8 @@ #include <unistd.h> #include <nuttx/debug.h> +#include <string.h> + #include <nuttx/signal.h> #include "sched/sched.h" @@ -127,6 +129,13 @@ int nxsig_kill(pid_t pid, int signo) /* Create the siginfo structure */ + /* Zero the whole siginfo first: sigaction-queued signals carry a + * si_user field that only the sigaction queue path assigns, so a + * stack-garbage si_user here would be memcpy'd into the pending + * entry and handed back to a sigtimedwait() consumer. + */ + + memset(&info, 0, sizeof(siginfo_t)); info.si_signo = signo; info.si_code = SI_USER; info.si_errno = EINTR; diff --git a/sched/signal/sig_tgkill.c b/sched/signal/sig_tgkill.c index b8237c6a7f6..810eaf5a0fc 100644 --- a/sched/signal/sig_tgkill.c +++ b/sched/signal/sig_tgkill.c @@ -31,6 +31,8 @@ #include <unistd.h> #include <nuttx/sched.h> +#include <string.h> + #include <nuttx/signal.h> #include "sched/sched.h" @@ -102,6 +104,13 @@ int nxsig_tgkill(pid_t pid, pid_t tid, int signo) /* Create the siginfo structure */ + /* Zero the whole siginfo first: sigaction-queued signals carry a + * si_user field that only the sigaction queue path assigns, so a + * stack-garbage si_user here would be memcpy'd into the pending + * entry and handed back to a sigtimedwait() consumer. + */ + + memset(&info, 0, sizeof(siginfo_t)); info.si_signo = signo; info.si_code = SI_USER; info.si_errno = EINTR;
