From nobody Sat Sep 05 00:35:35 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 4hcDrm2bqnz6qZjv for ; Sat, 05 Sep 2026 00:35:36 +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 4hcDrl5yNkz44Gj for ; Sat, 05 Sep 2026 00:35:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788568535; 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=DcoTWKUoX4Zf8kWuAFB5E32GfGyj/tSt3ToagzikFNs=; b=lxq97iMdjAlDcuoshXZCt0+GW0mojdO3GcNccUr1iU/RC2DB+Dv8B+5Xi7P8VP9V5iy03w iyuFryBHpkyDMbg5s/3haZFcD0CjAtrNA2cK8s1s6TtDvUdbwAPgggzVGFCBfmcg5cDaCH ZgGU8Me5Dv1tsGyUcVIi8j9J5eFP7LckXRfJwECvEuBBTsjwoLNGjPti052BlWZSsA81z5 kmx0oM4jEw2SqHUtH656+xAk9pejk2u/ESWI+8hj8PBfhQIRq2uwxHai69inXjsDjD/kUv c3Bi83tWrA3kS8ssds2wxr1MwGSk7JMFTsfS6XGQGzggFgA+PSasa4dF6OPZyw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788568535; a=rsa-sha256; cv=none; b=gEvATn/QjYqj5l6l1VqSlvLSbixj78q4EZ0lwt4K5KgL4WLC+g4MtubEiG9rmiSIUe34b9 eEj1RxZ89ggUt/+6jt04GSNsH2avP7WZVoe6c9uCOp4xFRu5RXWDb28YhZtIPXVN4RX7Cn OUZco+dhMGdCGGL2Sam3hywO+DG6lLI05sI4zHqrFWtc0nS9bbqnoDHWMJ96DSln4lxDwj ujcPNtTYjFbu7W0NX97NCBH2USKN/v+I2PmF2yih9wTbdazORD4cv8Fj2fNQamSmve33h2 3cydRRaH3FL4w1tLQVYK1eEUTxc0iWncFO2vcCe9KLNRhVb4931sqeqTTy3Tsg== 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=1788568535; 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=DcoTWKUoX4Zf8kWuAFB5E32GfGyj/tSt3ToagzikFNs=; b=PYzD4xqILzw8bIecieVNiWsKhUDLCHuhyhwgZ84+JkG95DTJd3u3Z64KFwep+iFO9y9tYH a15akDtJ09JclO9qUhFXyAn43JEB0g6hO5hiTVwlEFQuJpmEKimLpUaOKb95BOCtWSbB5r RAmRPss+dQUHUo+pFrqZwBKMMs9kmLvtThmnwC1oIO6pdV2Uxk0BjLWx9scq1tmP6jKItc EeMJSHWovOytAFgozDIb6jQhoocKaw+787RzH+CqOkYFxrM85P0mW7pbgp9ufABnaKdIAw A7QBVg7me01myDxqRlsn9zjalafCYwkAHuwAgMvQLV203Q5N7VxWFTpM8QuEXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hcDrl4f6bz7kl for ; Sat, 05 Sep 2026 00:35:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f2af by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 05 Sep 2026 00:35:35 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 201fd5bc4661 - stable/15 - pdfork.2: document cap mode, namely pdopenpid(2) and pdptrace(2) errors 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: 201fd5bc466185321d7fdfc4d49cc7f784095863 Auto-Submitted: auto-generated Date: Sat, 05 Sep 2026 00:35:35 +0000 Message-Id: <6a9b63d7.1f2af.765475ae@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=201fd5bc466185321d7fdfc4d49cc7f784095863 commit 201fd5bc466185321d7fdfc4d49cc7f784095863 Author: Konstantin Belousov AuthorDate: 2026-07-07 23:51:15 +0000 Commit: Konstantin Belousov CommitDate: 2026-09-05 00:33:43 +0000 pdfork.2: document cap mode, namely pdopenpid(2) and pdptrace(2) errors (cherry picked from commit 1ac08a43cf657564ebc2e036434e89552a6d3829) --- lib/libsys/pdfork.2 | 33 +++++++++++++++++++++++++++++++++ lib/libsys/ptrace.2 | 10 ++++++++++ 2 files changed, 43 insertions(+) diff --git a/lib/libsys/pdfork.2 b/lib/libsys/pdfork.2 index 6ac85f717d01..1806158e668f 100644 --- a/lib/libsys/pdfork.2 +++ b/lib/libsys/pdfork.2 @@ -176,6 +176,18 @@ specifying any file descriptors for the same process fail with the .Er ESRCH error. .Pp +The +.Fn pdopenpid +system call is allowed in the capability mode +.Pq see Xr capsicum 4 +when the target process is the child of the calling process, or +when the calling process is the debugger of the target process. +The debugger is attached to its target by +.Xr ptrace 2 , +.Xr pdptrace 2 , +or by other means, e.g., by debugging the target process' parent with +the follow-on-fork mode enabled. +.Pp .Fn pdgetpid queries the process ID (PID) in the process descriptor .Fa fd . @@ -454,6 +466,27 @@ The specified process does not have a file descriptor table. refers to a file that cannot be duplicated across a process boundary, such as a kqueue. .El +.Pp +The +.Fn pdptrace +system call returns the same errors as +.Xr ptrace 2 , +as well as the following specific errors: +.Bl -tag -width Er +.It Bq Er ECAPMODE +The process issuing the +.Fn pdptrace +call is in capability mode, +and the +.Dv security.bsd.allow_ptrace_in_cap_mode +tunable is set to +.Dv false . +.It Bq Er ENOTCAPABLE +The process called +.Fn pdptrace +on the process descriptor that does not have the +.Dv CAP_PTRACE +capability enabled. .Sh SEE ALSO .Xr close 2 , .Xr fork 2 , diff --git a/lib/libsys/ptrace.2 b/lib/libsys/ptrace.2 index 612de4c5fc31..2f620155eed9 100644 --- a/lib/libsys/ptrace.2 +++ b/lib/libsys/ptrace.2 @@ -180,6 +180,12 @@ process, even if the requesting process' jail is an ancestor of the target process'. These requests will fail with error .Er ESRCH . +.It Dv security.bsd.allow_ptrace_in_cap_mode +Setting this sysctl to true allows the +.Fn ptrace +requests issued by the processes in capability mode, +see +.Xr pdptrace 2 . .It Dv securelevel and init The .Xr init 1 @@ -1522,6 +1528,10 @@ enough. .Fa pve_pathlen holds the minimum buffer size required on return. .El +.It Bq ECAPMODE +The process issuing the +.Fn ptrace +call is in capability mode. .El .Sh SEE ALSO .Xr execve 2 ,