git: bce6e0e90328 - stable/15 - ptrace: clear TDP_USERWR after transparent attach only on attach

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 17 May 2026 00:29:39 UTC
The branch stable/15 has been updated by kib:

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

commit bce6e0e903288aa128bdd8ec45005d1416c4c764
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-05-11 01:12:30 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-05-17 00:27:48 +0000

    ptrace: clear TDP_USERWR after transparent attach only on attach
    
    (cherry picked from commit cb31a266167c8bde3488fbdd6bf24c38b6f59977)
---
 sys/kern/sys_process.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index c67996ad7df1..7225a63328b4 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -1377,17 +1377,16 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
 		 * register file or specifying the pc, make the thread
 		 * xstopped by waking it up.
 		 */
-		if ((td2->td_dbgflags & TDB_USERWR) != 0) {
-			if (pt_attach_transparent) {
-				thread_lock(td2);
-				if (TD_ON_SLEEPQ(td2) &&
-				    (td2->td_flags & TDF_SINTR) != 0) {
-					sleepq_abort(td2, EINTR);
-				} else {
-					thread_unlock(td2);
-				}
+		if ((td2->td_dbgflags & TDB_USERWR) != 0 &&
+		    pt_attach_transparent) {
+			thread_lock(td2);
+			if (TD_ON_SLEEPQ(td2) &&
+			    (td2->td_flags & TDF_SINTR) != 0) {
+				td2->td_dbgflags &= ~TDB_USERWR;
+				sleepq_abort(td2, EINTR);
+			} else {
+				thread_unlock(td2);
 			}
-			td2->td_dbgflags &= ~TDB_USERWR;
 		}
 
 		/*