From nobody Sat Sep 05 00:35:24 2026 X-Original-To: dev-commits-src-branches@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 4hcDrY2VKZz6qZdg for ; Sat, 05 Sep 2026 00:35:25 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hcDrX6tyKz43tK for ; Sat, 05 Sep 2026 00:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788568525; 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=gcQrCTuguT2/LbFr9f7ykhwnvzrHK6r1xuJ5HPFZLEY=; b=MkeJmWxFKOkMuaFB+D1rRPM31nn2B2GX0ZmG968b2H+loOGOvYxgAEFYyibu3YpUC9owvY qNHdeTV0Z4t0CiXcRP2exl330/nEHdQmqaAik4bXmAFIX8FQoyxpSilj7e+XfHp233T8pd qtcRD30BpRGroTAbw7ui2q1ODkriux+3y74pHEtf34dIVY0KrA7yr2GBZV1X+fuyHFq7sH htw0ivlFp0ATFOT8aawldNmA38Y7g3kVwvNEWpN34dinpo4wXJHqVqYwFY1/BGGb4lsz6p wNxwRWvqu5lsqE07tVdwc5TcAKpTH1ehd60gL+g4i9cPT2H4Vy8PbcS6K7lBew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788568525; a=rsa-sha256; cv=none; b=iBtBe0F7GgvjlzoHm3rOsJi15n3mIMfzelDtOc4upryUxv0YpkBrLAZxNzHZIbBmSepW91 kkWi9AEp6F7wEo6M56ocPGWqKNxoJPXW+iBKJz2o/P0f3BFeNiTyV3G1uWjDSJs2HnvEHH VrWnYm9j2ZfJy2YL8WNVGCTytPrFO/llI/eI7FO7Bx16yODrnLSyRq0H0C92JAgb+C0SkN peWk4whaPe0ETDxBLi0s0xmM/JtMgMjzbjt9uxAvkafuIPNmXanWg7P+JFwyrtGW6uCo2E +w/GuZwxFZNa5kDpZmgFPC5/Il6HQENfBiCCSAYrXkbHcgyoiY8BFnuvBK+Hpg== 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=1788568525; 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=gcQrCTuguT2/LbFr9f7ykhwnvzrHK6r1xuJ5HPFZLEY=; b=G6IFUHtf+CZOFM1z6MlFI1XvacXE4OIxrOeCBslPDw+syMGIqCjLL/3TurBi1MvQ05hLug GEXIQ6SDYdGO7Ov0W5TuQ9s4vOoK1uCRtikfVHvpYu/kGdpZ7A6wy3K9m8ykYw4efO6/IC Ei4lKkXYzfxDWn95aB/Z6+fQd2NU4BMM5RlcxWei3k6mjYUr8dURWegXgeJ6uRWgagL5S6 jeLaMOPh2hwKefBjiPoMV+dUoffpsW1Ky9xqTcE+DEMWmd/q8aSfOyv9Lh0hIOBDRc8I5b 5MZckuB+7cwEb+E3BcX2s4yB+bxRrjNyf8Ak0nmKm3ATzCTkWRXXkFzoefOI3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hcDrX5nJJz78m for ; Sat, 05 Sep 2026 00:35:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f2ab by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 05 Sep 2026 00:35:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 48e709bbbda2 - stable/15 - pdfork.2, rights.4: document pdptrace(2), CAP_PTRACE, and pdfork(PD_PTRACE_CAP) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 48e709bbbda209d46183a42e74b4dd1bda5ec12f Auto-Submitted: auto-generated Date: Sat, 05 Sep 2026 00:35:24 +0000 Message-Id: <6a9b63cc.1f2ab.7b02900e@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=48e709bbbda209d46183a42e74b4dd1bda5ec12f commit 48e709bbbda209d46183a42e74b4dd1bda5ec12f Author: Konstantin Belousov AuthorDate: 2026-07-19 22:56:32 +0000 Commit: Konstantin Belousov CommitDate: 2026-09-05 00:33:40 +0000 pdfork.2, rights.4: document pdptrace(2), CAP_PTRACE, and pdfork(PD_PTRACE_CAP) (cherry picked from commit 45633600acade39cccc3b8daace7b3aeeb1f5b07) --- lib/libsys/pdfork.2 | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- lib/libsys/ptrace.2 | 1 + share/man/man4/rights.4 | 3 +++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/libsys/pdfork.2 b/lib/libsys/pdfork.2 index 3c18a0f4130c..6ac85f717d01 100644 --- a/lib/libsys/pdfork.2 +++ b/lib/libsys/pdfork.2 @@ -66,6 +66,14 @@ .Fc .Ft int .Fn pddupfd "int fd" "int remotefd" "int flags" +.Ft int +.Fo pdptrace +.Fa "int req" +.Fa "int fd" +.Fa "int lwpid" +.Fa "void *addr" +.Fa "int data" +.Fc .Sh DESCRIPTION Process descriptors are special file descriptors that represent processes, and are created using @@ -83,7 +91,7 @@ on termination. .Fn pdfork can accept the .Fa pdflags: -.Bl -tag -width PD_CLOEXEC +.Bl -tag -width PD_PTRACE_CAP .It Dv PD_DAEMON Instead of the default terminate-on-close behaviour, allow the process to live until it is explicitly killed with @@ -106,6 +114,16 @@ Set close-on-exec on process descriptor. .It Dv PD_NOWAITPID The parent cannot obtain the child's status with .Xr waitpid 2 . +.It Dv PD_PTRACE_CAP +Enable +.Xr pdptrace 2 +requests on the resulting file descriptor. +Otherwise the descriptor cannot be used to debug the child process. +See +.Xr rights 4 +for the description of the +.Dv CAP_PTRACE +capability. .El .Pp The @@ -197,6 +215,32 @@ The argument is reserved and must be zero. Certain file descriptor types cannot be copied this way, namely kqueues. +.Pp +The +.Fn pdptrace +function enables execution of +.Xr ptrace 2 +requests on the process specified by the process descriptor +.Fa fd . +.Pp +In addition to the arguments taken by the +.Xr ptrace 2 , +system call, the +.Fa lwpid +thread identifier can designate the thread on which the request +must operate. +The +.Fa lwpid +argument can be specified as \-1 if the call is not thread-specific, +or kernel is allowed to select some thread on its own. +.Pp +Unlike the +.Xr ptrace 2 +implementation, +.Fn pdptrace +does not clear the +.Dv errno +variable before executing the system call. .Sh INTERACTION OF PROCESS DESCRIPTORS AND Xr WAITPID 2 .Pp The @@ -461,8 +505,9 @@ functions were developed by with input from .An Alan Somers Aq Mt asomers@FreeBSD.org . The -.Fn pdopenpid +.Fn pdopenpid , +.Fn pddupfd , and -.Fn pddupfd +.Fn pdptrace functions were developed by .An Konstantin Belousov Aq Mt kib@FreeBSD.org . diff --git a/lib/libsys/ptrace.2 b/lib/libsys/ptrace.2 index cedcf92cbef1..c8513c7ba12d 100644 --- a/lib/libsys/ptrace.2 +++ b/lib/libsys/ptrace.2 @@ -1514,6 +1514,7 @@ holds the minimum buffer size required on return. .El .Sh SEE ALSO .Xr execve 2 , +.Xr pdptrace 2 , .Xr sigaction 2 , .Xr wait 2 , .Xr execv 3 , diff --git a/share/man/man4/rights.4 b/share/man/man4/rights.4 index 396222a84579..93489300d161 100644 --- a/share/man/man4/rights.4 +++ b/share/man/man4/rights.4 @@ -484,6 +484,9 @@ Permit .It Dv CAP_PDKILL Permit .Xr pdkill 2 . +.It Dv CAP_PTRACE +Permit debugging using +.Xr pdptrace 2 . .It Dv CAP_PDWAIT Permit .Xr pdwait 2 .