git: a24afbb4e633 - main - Ignore debugger-injected signals left after detaching

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 12 Jan 2022 05:41:53 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=a24afbb4e633f6725dfe3de099b8e2a4f6b1b631

commit a24afbb4e633f6725dfe3de099b8e2a4f6b1b631
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-08 09:46:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-12 05:33:30 +0000

    Ignore debugger-injected signals left after detaching
    
    PR:     261010
    Reported by:    Martin Simmons <martin@lispworks.com>
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D33787
---
 sys/kern/kern_sig.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 0b74ebe80cdd..4a15bd453557 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2992,8 +2992,10 @@ sigprocess(struct thread *td, int sig)
 		 * and p_sigact are consistent.
 		 */
 		if ((p->p_flag & P_TRACED) == 0) {
-			ksi.ksi_flags |= KSI_HEAD;
-			sigqueue_add(queue, sig, &ksi);
+			if ((ksi.ksi_flags & KSI_PTRACE) == 0) {
+				ksi.ksi_flags |= KSI_HEAD;
+				sigqueue_add(queue, sig, &ksi);
+			}
 			return (SIGSTATUS_HANDLED);
 		}
 	}