Index: sys/kern/sys_ptrace_common.c =================================================================== RCS file: /cvsroot/src/sys/kern/sys_ptrace_common.c,v retrieving revision 1.59 diff -u -r1.59 sys_ptrace_common.c --- sys/kern/sys_ptrace_common.c 30 Sep 2019 21:13:33 -0000 1.59 +++ sys/kern/sys_ptrace_common.c 1 Oct 2019 18:32:58 -0000 @@ -688,6 +688,7 @@ static int ptrace_get_process_state(struct proc *t, void *addr, size_t data) { + struct _ksiginfo *si; struct ptrace_state ps; if (data != sizeof(ps)) { @@ -698,20 +699,20 @@ if (t->p_sigctx.ps_info._signo != SIGTRAP || (t->p_sigctx.ps_info._code != TRAP_CHLD && t->p_sigctx.ps_info._code != TRAP_LWP)) { - return EINVAL; - } - - ps.pe_report_event = - t->p_sigctx.ps_info._reason._ptrace_state._pe_report_event; + memset(&ps, 0, sizeof(ps)); + } else { + si = &t->p_sigctx.ps_info; + ps.pe_report_event = si->_reason._ptrace_state._pe_report_event; - CTASSERT(sizeof(ps.pe_other_pid) == - sizeof(t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid)); - CTASSERT(sizeof(ps.pe_lwp) == - sizeof(t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid)); - CTASSERT(sizeof(ps.pe_other_pid) == sizeof(ps.pe_lwp)); + CTASSERT(sizeof(ps.pe_other_pid) == + sizeof(si->_reason._ptrace_state._option._pe_other_pid)); + CTASSERT(sizeof(ps.pe_lwp) == + sizeof(si->_reason._ptrace_state._option._pe_other_pid)); + CTASSERT(sizeof(ps.pe_other_pid) == sizeof(ps.pe_lwp)); - ps.pe_other_pid = - t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid; + ps.pe_other_pid = + si->_reason._ptrace_state._option._pe_other_pid; + } DPRINTF(("%s: lwp=%d event=%#x pid=%d lwp=%d\n", __func__, t->p_sigctx.ps_lwp, ps.pe_report_event,