From nobody Sun Apr 27 21:52:48 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Zm0gP3gGLz5vNDc; Sun, 27 Apr 2025 21:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zm0gP02hHz3RQN; Sun, 27 Apr 2025 21:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745790769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kUJRog9L2nW0H4HSJo+lN1Kej9DiYvZDlaLjWDiN0uY=; b=JdeRVSDuA5ufURbrupFw73+Zr+gmEGJl8rml0uodtye1Rzr6cnBjwkZwJMt3yPdUR6nAcq 8vRbk54ykYVe9CBlMoHg0h8h93MmxrW0txdKp0gOGWxp35h0AHTCGxSjb5QtoEnGzNogVw 1j66xRVW/xAI0HKXAMLtZYqc4WThxduzFmEDlGSYo9l8vEe8ltCf2q8sblrIzLCfDlX0hL cyBzwzZlE2KjyuJ4aLFYKxjm2rB7aZ2iubhzCzEL4scHzHr6Trm7jfVLhmX9S5GhjUjfK8 BuxzVdwbC+t9uDi21/0nR/b6O4fBseEkatq8Gcj3o8v8vvdGOiI5j4m1MGUjVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745790769; a=rsa-sha256; cv=none; b=Bzi6wWzlUQSmh24pxRkk80R8xwZCHioFLyAIqBOYCDuxTkSFfkfI5j99i7RqRHxjsITsYf M3BKRXfZlW+O1F5dh3n7B+mJ5lw1bunvVufuEYiD5HoRhFoK+7uRx6Phbjh1jtkNRoAeXJ S4vo6D6YOLn1cjcN6nvEuwuEn1FiF03mHke5cXQ1VqgrqckXIrN2/jh1irF7PndiICz3/V YN4xO0ODLKryO+T/rnuuMfgCdYn2Laa2nzGwclljw0m6bTn0M2ouC2NN9vh7w+tnH4SuLQ ddH9cq3/57pH6zNwfdD3hRpD7Uux/Ddauu4pOX1oR5Wkx73Vlb5vbT/Pmh1+IA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745790769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kUJRog9L2nW0H4HSJo+lN1Kej9DiYvZDlaLjWDiN0uY=; b=FWqNjY/xf3zW4ffaViWZ8dfNXjSsCyDJvdRQD+ejCq785/Uxa6Z5X6USghYqUVzfX6/nfR ShqEsSAB5/1bElMe7CYLyya97XRKhriyqxX8KHio09g4JML1NPj34e3eORvpUCELy5367e Sje6IwGZbSfo0dD/t7wATkQ5jXvphSvMq3ICvBE104j6OGkF7tGm5lvWRhoRpGSEijwDXT qKV1Ts2xZMg9jLlAk6uldz+aBfQx6HyEU+FCYcKRi9itMCoHJYFLU7KVRCwvwxwYVYGw6S N2+jxvZKLG+3Qqz1yXTHVjGpiEB4Lm85myHrhYhKERKEonXr8XlBklIy7EbIeA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Zm0gN6jkcz1M8n; Sun, 27 Apr 2025 21:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53RLqmfg093927; Sun, 27 Apr 2025 21:52:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53RLqmI9093924; Sun, 27 Apr 2025 21:52:48 GMT (envelope-from git) Date: Sun, 27 Apr 2025 21:52:48 GMT Message-Id: <202504272152.53RLqmI9093924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f87811ca3bc1 - main - sig_handle_first_stop(): allow NULL leader thread List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f87811ca3bc110af29e3a0e341d241c292dc8424 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f87811ca3bc110af29e3a0e341d241c292dc8424 commit f87811ca3bc110af29e3a0e341d241c292dc8424 Author: Konstantin Belousov AuthorDate: 2025-04-21 12:54:32 +0000 Commit: Konstantin Belousov CommitDate: 2025-04-27 21:52:12 +0000 sig_handle_first_stop(): allow NULL leader thread Remove the ext argument, the ext condition is indicated by NULL td. If the td argument is NULL, p_xthread is set to NULL, for initial attach. Previous commit prepared ptrace() code for the case. sig_suspend_thread() only uses the td arg to avoid interrupting the current thread as micro-optimization, so it is fine to pass NULL. Tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D49961 --- sys/kern/kern_sig.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 91287b3c1f87..2724944bb7a2 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -116,7 +116,7 @@ static struct thread *sigtd(struct proc *p, int sig, bool fast_sigblock); static void sigqueue_start(void); static void sigfastblock_setpend(struct thread *td, bool resched); static void sig_handle_first_stop(struct thread *td, struct proc *p, - int sig, bool ext); + int sig); static uma_zone_t ksiginfo_zone = NULL; const struct filterops sig_filtops = { @@ -2373,9 +2373,8 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) if (pt_attach_transparent && (p->p_flag & P_TRACED) != 0 && (p->p_flag2 & P2_PTRACE_FSTP) != 0) { - td->td_dbgflags |= TDB_FSTP; PROC_SLOCK(p); - sig_handle_first_stop(td, p, sig, true); + sig_handle_first_stop(NULL, p, sig); PROC_SUNLOCK(p); return (0); } @@ -2838,11 +2837,10 @@ sig_suspend_threads(struct thread *td, struct proc *p) } static void -sig_handle_first_stop(struct thread *td, struct proc *p, int sig, bool ext) +sig_handle_first_stop(struct thread *td, struct proc *p, int sig) { - if ((td->td_dbgflags & TDB_FSTP) == 0 && - ((p->p_flag2 & P2_PTRACE_FSTP) != 0 || - p->p_xthread != NULL)) + if (td != NULL && (td->td_dbgflags & TDB_FSTP) == 0 && + ((p->p_flag2 & P2_PTRACE_FSTP) != 0 || p->p_xthread != NULL)) return; p->p_xsig = sig; @@ -2852,7 +2850,7 @@ sig_handle_first_stop(struct thread *td, struct proc *p, int sig, bool ext) * If we are on sleepqueue already, let sleepqueue * code decide if it needs to go sleep after attach. */ - if (ext || td->td_wchan == NULL) + if (td != NULL && td->td_wchan == NULL) td->td_dbgflags &= ~TDB_FSTP; p->p_flag2 &= ~P2_PTRACE_FSTP; @@ -2920,7 +2918,7 @@ ptracestop(struct thread *td, int sig, ksiginfo_t *si) * already set p_xthread, the current thread will get * a chance to report itself upon the next iteration. */ - sig_handle_first_stop(td, p, sig, false); + sig_handle_first_stop(td, p, sig); if ((td->td_dbgflags & TDB_STOPATFORK) != 0) { td->td_dbgflags &= ~TDB_STOPATFORK;