From 8804fddd1a4c68f3b947e045f26c1f7b721552e1 Mon Sep 17 00:00:00 2001 From: claudio Date: Sun, 6 Feb 2022 09:57:59 +0000 Subject: [PATCH] Simplify cursig() a bit and make sure that signals are always sent to the parent of ptraced processes. Especially ignore the signal mask set by sigprocmask(2) in that case. In userret() alter the testcase for when to call cursig() which is only there to avoid taking the KERNEL_LOCK when returning from a MP safe syscall. This can be revisited once cursig() is MP safe. Problem with debugging signal handlers found by kurt@ Tested and OK kurt@, OK mpi@ --- sys/kern/kern_sig.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 4103b2a0196..c738f056a9d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.292 2022/01/02 21:01:20 tb Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.293 2022/02/06 09:57:59 claudio Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1194,21 +1194,16 @@ int cursig(struct proc *p) { struct process *pr = p->p_p; - int sigpending, signum, mask, prop; + int signum, mask, prop; int dolock = (p->p_flag & P_SINTR) == 0; int s; KERNEL_ASSERT_LOCKED(); - sigpending = (p->p_siglist | pr->ps_siglist); - if (sigpending == 0) - return 0; - - if (!ISSET(pr->ps_flags, PS_TRACED) && SIGPENDING(p) == 0) - return 0; - for (;;) { - mask = SIGPENDING(p); + mask = (p->p_siglist | pr->ps_siglist); + if (!ISSET(pr->ps_flags, PS_TRACED)) + mask &= ~p->p_sigmask; if (pr->ps_flags & PS_PPWAIT) mask &= ~STOPSIGMASK; if (mask == 0) /* no signal to send */ @@ -1919,7 +1914,7 @@ userret(struct proc *p) KERNEL_UNLOCK(); } - if (SIGPENDING(p) != 0) { + if (SIGPENDING(p) != 0 || ISSET(p->p_p->ps_flags, PS_TRACED)) { KERNEL_LOCK(); while ((signum = cursig(p)) != 0) postsig(p, signum); -- 2.20.1