From nobody Sun Apr 07 23:57:09 2024 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 4VCTfZ0HCJz5Fb9v; Sun, 7 Apr 2024 23:57:10 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VCTfY5Fcsz4CS8; Sun, 7 Apr 2024 23:57:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712534229; 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=+gwWJI06ToWwPA/vVtDxlOK4Vt6SxXj2tcT5ktoJ4Lc=; b=hpzruzK/xWzygRjhF8X3nAmhykiaAn1zNs3mLPLefHNsX1Qb7uyHYlmDKJKpXQODas2cLp qfOcSd95KtN1r3zD3alj118qH427Emic0D8Lgto2gceFA1vGOXn6UiUEDOycmmoXZfQq2q KVHlgWBmSZJqRUW7Ga187Eqh4YFGv3tc63kIJ/wThXmmjKU7mXlbdeqOot7yF1lTvjB00V DP79FgU3tgljovmJtmGC0RIBpDlAXL1y6t46SsCC9H1QQXx5VO8viE+ML+uVqmSAw9kjdN Lx7egWUdlgqkc71c+OhY5sX6AJbGSW6IXXkxCyGB6FAquGbGaoAnxDlAjVPMHA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712534229; a=rsa-sha256; cv=none; b=qlqpGdaiEDOheBxCbcrnKSkFRgjEMTfZIzVSocPi/iY/dbqzRBU4eQDAGsZbFr6bGeghAF GAIoeuWC1DlmA9+wZuRvYPW8AVHNXe6se08L42zKFfTXVUqOTb4DCzgUSlk85wQz6d6qp9 IExOhU8dGRI2v2jqpqzONYuxvnVsjuJfrrmhAjIboK1uO+pCp3w/OXdmurazaMT8r0YFrW ZqvTKGrDzFukxiEu22Ey0LTx0fr/bwX3PrUohcj/VQMf1Vx2f5MkLm2+/rdrTChYiLkvDN WvcnjL8fnEPCeQiIx9qPjoEVECa0pRKfCK28L0DyiecrdGdmRAc6OdeEktDwjA== 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=1712534229; 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=+gwWJI06ToWwPA/vVtDxlOK4Vt6SxXj2tcT5ktoJ4Lc=; b=IRa7Sryiz8DlX9jhGtQBhenFqDxdK/Mt3uBNZcP3hxc+5ya/dbJc7XYSlIpWVNue5FWsGe K7DdhhVHwvTV5tLiSPqyFIwzWpssvd/TSoiOe3u15I8KkZ2ZpsMZ7yIOG+0wTZP2920O5E kpL5xCQYxNHB241GhgGDvynhUviGw4PaQYCi6rh/OMlHz7h5LcX353L3IcSvOn4BCdlbLt 6uOa77xvs43Us2rj0PLBPgcxYp9ZhzP8rK82H7ZxGI4999kiSG4vriNmBG4sMLsFs2hAM2 9XorVBnML3uAbEEyvxg3QSA+cEhx6l0DQ2zbauPMy6qkLXltIIt7IKDjCypUpQ== 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 4VCTfY4qv9znpH; Sun, 7 Apr 2024 23:57:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 437Nv9Io037479; Sun, 7 Apr 2024 23:57:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 437Nv93c037476; Sun, 7 Apr 2024 23:57:09 GMT (envelope-from git) Date: Sun, 7 Apr 2024 23:57:09 GMT Message-Id: <202404072357.437Nv93c037476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jake Freeland Subject: git: 6a4616a529c1 - main - ktrace: Record signal violations with KTR_CAPFAIL 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jfree X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6a4616a529c1e387d87376e48ceb670eef8141e7 Auto-Submitted: auto-generated The branch main has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=6a4616a529c1e387d87376e48ceb670eef8141e7 commit 6a4616a529c1e387d87376e48ceb670eef8141e7 Author: Jake Freeland AuthorDate: 2024-04-06 18:31:21 +0000 Commit: Jake Freeland CommitDate: 2024-04-07 23:52:51 +0000 ktrace: Record signal violations with KTR_CAPFAIL Report the delivery of signals to processes other than self while Capsicum violation tracing with CAPFAIL_SIGNAL. Reviewed by: markj Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D40679 --- sys/kern/kern_procctl.c | 4 ++++ sys/kern/kern_sig.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c index 4d145f9737a0..46ddfaf709bd 100644 --- a/sys/kern/kern_procctl.c +++ b/sys/kern/kern_procctl.c @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#include "opt_ktrace.h" + #include #include #include @@ -542,6 +544,8 @@ reap_kill(struct thread *td, struct proc *p, void *data) rk = data; sx_assert(&proctree_lock, SX_LOCKED); + if (CAP_TRACING(td)) + ktrcapfail(CAPFAIL_SIGNAL, &rk->rk_sig); if (IN_CAPABILITY_MODE(td)) return (ECAPMODE); if (rk->rk_sig <= 0 || rk->rk_sig > _SIG_MAXSIG || diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 8fa0942a5496..11b3a3374a4d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1906,8 +1906,12 @@ kern_kill(struct thread *td, pid_t pid, int signum) * The main rationale behind this is that abort(3) is implemented as * kill(getpid(), SIGABRT). */ - if (IN_CAPABILITY_MODE(td) && pid != td->td_proc->p_pid) - return (ECAPMODE); + if (pid != td->td_proc->p_pid) { + if (CAP_TRACING(td)) + ktrcapfail(CAPFAIL_SIGNAL, &signum); + if (IN_CAPABILITY_MODE(td)) + return (ECAPMODE); + } AUDIT_ARG_SIGNUM(signum); AUDIT_ARG_PID(pid);