From nobody Thu May 29 14:29:43 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 4b7TKM5w2Zz5x5Fj; Thu, 29 May 2025 14:29:43 +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 4b7TKM56Wzz3lQ3; Thu, 29 May 2025 14:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748528983; 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=MJssb6Nze/WaRVApie8b1qp/h8+64VlouZk3w+/bhmg=; b=hEnOML8YA/M4+WItuKJjlem95ToD+v8k6BiQ0ayMz7mknBkbWfJvrwDBMja5RI1vttwE2f Ew3NV6ay2mXKBjdpxiZgLS3dyzR5SW8VM6Un/EfyoYvAeLGQ5QNmqjNA0KzD5BdI4gtBs6 cKCKfV8/4UheYXvAB57Li1ckWss1IwUKB0d3DcLX0r3qhlr6cdcrq8hkiOzpQnGyRPXvtm v8GdZ6frAYfb3l3u65fRp/GbyHq7i/DP1ZRHJW4yGudi5t8t/i/yQ/J0YodQUJM6DB9hri ytxaItvM6OZdt7reW4RB/LjbJAaH3+mDbchiasgP7A4F7Irl+taqag6DV5oanQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748528983; a=rsa-sha256; cv=none; b=X/O+T41xmBg7YufdDZItHXrjimoQmXQXqk8i9EsNQ+Vp9lG9fhP21j1ACxHGbbct+tt9/g PybQ2by/L3tAlZQRO/fET+msw2a1xj9bG+MUR6M/bBGnafpPBMvLt1nZfcLPqvlOHaLK6H 7+VpYG8guRSjrFk35X8EYG+mC1W0xUdS7Ge7uhczxtwRICsgP6XboM3glik/rJJW3qg4mB oq98mHxGG5aKYt0YdPkewxtp/9vhqgV9L/SPuabPpSnUWzRpw62HAW4T7sZVMbBO7io6W/ ysDnvBC8R4328iYQ+oKCmAtFo1IUasRgWZwTIwHLUH51YoDWZp7w9A+x5haMzQ== 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=1748528983; 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=MJssb6Nze/WaRVApie8b1qp/h8+64VlouZk3w+/bhmg=; b=BVjOHoo6+ler2zYsU/gF+qPAPHVhRs5rm+Vwa+WIxTm/E/oIHyC4iBfpqhPcZTzFqZEJW3 bB3xZIygIUYROR2NYFw8AZnDqEUfle04gV3tWRyuUoH6DhiyiOIUD8CSIe8eQR2hjjYWyW hWvKFHXRNI+ETMqoDjyjlBtnpJcjk88QCWm9Pqk3QPoNPTpFqKvZnCyWJQEflsrBHjsdfO N1QpEk2JgdrgXuOW46+zXKjhhy+pcJ6IF9meg6MMvJ+N1XmBOMV2SsAdlhZGbyE3QgVmpX u9OGdLncKRrcQFNMjKoWPCBr1mCmMO4LoPRnxWWBSHS81GmDflR9HiKvSsA8Lg== 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 4b7TKM4dkBz1PkN; Thu, 29 May 2025 14:29:43 +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 54TEThqp011650; Thu, 29 May 2025 14:29:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54TEThc1011647; Thu, 29 May 2025 14:29:43 GMT (envelope-from git) Date: Thu, 29 May 2025 14:29:43 GMT Message-Id: <202505291429.54TEThc1011647@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: 99976934274d - main - PT_CONTINUE: undo transparent attach consequences 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: 99976934274de6fa19f049a0b6eac10856710f96 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=99976934274de6fa19f049a0b6eac10856710f96 commit 99976934274de6fa19f049a0b6eac10856710f96 Author: Konstantin Belousov AuthorDate: 2025-05-27 21:09:18 +0000 Commit: Konstantin Belousov CommitDate: 2025-05-29 14:28:06 +0000 PT_CONTINUE: undo transparent attach consequences PR: 287050 Reported and tested by: Paul Floyd Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50556 --- sys/kern/sys_process.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 35112f6c29d1..8b382cb3048e 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -1346,6 +1347,27 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) if (data == SIGKILL) proc_wkilled(p); + /* + * If the PT_CONTINUE-like operation is attempted on + * the thread on sleepq, this is possible only after + * the transparent PT_ATTACH. In this case, if the + * caller modified the thread state, e.g. by writing + * 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); + } + } + td2->td_dbgflags &= ~TDB_USERWR; + } + /* * Unsuspend all threads. To leave a thread * suspended, use PT_SUSPEND to suspend it before