git: a5f698599560 - stable/13 - Ignore debugger-injected signals left after detaching

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 16 Jan 2022 02:54:09 UTC
The branch stable/13 has been updated by kib:

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

commit a5f69859956049b5153b0e1b67f8f4a99622dc6f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-08 09:46:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-15 12:55:32 +0000

    Ignore debugger-injected signals left after detaching
    
    PR:     261010
    
    (cherry picked from commit a24afbb4e633f6725dfe3de099b8e2a4f6b1b631)
---
 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 6f656ba92107..8680b30aa651 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3009,8 +3009,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);
 		}
 	}