From nobody Fri Aug 28 12:05:20 2026 X-Original-To: dev-commits-src-all@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 4hWcXK2fhXz6qH64 for ; Fri, 28 Aug 2026 12:05:21 +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 4hWcXJ48Vxz3Bv5 for ; Fri, 28 Aug 2026 12:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787918720; 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=AoMNaQfRyL4P00ZxQNxrtU7Yw8x9MBbk+bKZQm60bsM=; b=fIsloUMpe/+NrG39jwbkXEl3PCRnQXGV4tDSPXHiCe25KodVcmJkaYNKWanBCG/6yfzubW JpxffnvkIa9LHM4eJZmoiFVrx6yp1gZnTXByzBRaNyFPweqlFJDS/NZZIxPfiICmHHi9aV sxIhmUcLR96wm1gN/cbhFZmOzaccBzZqBiDdeWEHxCjuZno8ZtpKn7ctZYc0F/hry+VZxm Qu81+UTUw5u5626B7epdlZznAXUb/a+AV8pRVLw7uT72RB4E+JvtrQyxTXj5h0FjsJzrTH t4as4r07StoGmwLPPo9rR2DGMiAyCBcFqSoh81hJmelMSudGgcwSn+usdWso/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787918720; a=rsa-sha256; cv=none; b=osuttuKAG6apjLK8E8BP6qpac6cWLv4+wYMewS56Ar358fldK48eNaKZ4Y5pVHt+Re/xuh wt5QeuxNNZxD9FB9HXUjSKVn8haWc+7/TPq4wzddHxqi8xkAb/T2fhTwdTZK+Cvx+IFNfR BOnG2gx0w701ek2K5vpJqsQ7noCgmFbmJ6DTfeBNq1NJ15xtLH8cPrhUyncvqtS9Bh4yT2 3tPOq7kSpGJ4cJ0wk36ErvYeUmFA8AEku3X9KAmt6rKT+lGZXVVLNKWPtr5B2rXXNA0Rpt c4QwpG0vRgkzzxXhscDq5TgpSM1XK4b3HLyAgtUq9ZwiFFdMUPToFvwG9Z7i8w== 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=1787918720; 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=AoMNaQfRyL4P00ZxQNxrtU7Yw8x9MBbk+bKZQm60bsM=; b=eqzCY3XypCWF0woIjPrXrOwB4bDGFU4Kf3SRH0OxCG6fg+BmLBBv27s+nFVi6N+6G3S5fy /Pi8yl5uG2mtG+gZtkqCpRl6ZnLBGiTaspRvRKpg6oNapZJjfxREMBbF/2siVyIQYBbDc/ xG05taX5AgF+C7Qmt/1snps7FV3WnqR5ptpDg41sbA5O6WocpLxZnE4LTAujVlgwVC2WzR Mtdt0DFZowInwnOesdGVC7e53s8qbodUK5agLoPAWeEH3uf84RMSwLQRls4X41uOlz/VpH yA+OsHlgtaQD4EJKSjbqYeysauH+mVIvemXq18eSeKmVti18uJx7BbTg82Y8ng== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hWcXJ24RDz18JQ for ; Fri, 28 Aug 2026 12:05:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25e71 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 28 Aug 2026 12:05:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1ac08a43cf65 - main - pdfork.2: document cap mode, namely pdopenpid(2) and pdptrace(2) errors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 1ac08a43cf657564ebc2e036434e89552a6d3829 Auto-Submitted: auto-generated Date: Fri, 28 Aug 2026 12:05:20 +0000 Message-Id: <6a917980.25e71.4a593657@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1ac08a43cf657564ebc2e036434e89552a6d3829 commit 1ac08a43cf657564ebc2e036434e89552a6d3829 Author: Konstantin Belousov AuthorDate: 2026-07-07 23:51:15 +0000 Commit: Konstantin Belousov CommitDate: 2026-08-28 11:55:11 +0000 pdfork.2: document cap mode, namely pdopenpid(2) and pdptrace(2) errors Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D58989 --- 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 ,