From nobody Sun May 12 00:08:29 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 4VcNHx5hb0z5JbZh; Sun, 12 May 2024 00:08:29 +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 4VcNHx46THz4sjk; Sun, 12 May 2024 00:08:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715472509; 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=+tCjWBMDLeYRJyOSrR0s74hKQJuwtjmA3kZbxRsG30I=; b=NwFFclDm2qLUqUu+Hh2Zai9R9zynGeJtTGOm7u7ALAu6m12LuKyqSLjJ0qA+d9pJxYjjoz mtECjEoiyrPhbx7aIf+9A0Cfi5Kp/ljJXexGnZFckAEqACOZP3HiVhdSOEQ6fv5lOzQrRI n5X472BlcWbCt/nZVYR1CSDQ79SuvMzB0D4pPQXrxkXL6hwPlE0VWzr4W6w5E7ZAasTeZM CUpfe8FVve9/VIKVqfQ/kkRmVtg+aapoV3z5gCG8sraSIzKCMrUcOQi/HGp8YgBAR8Fw/0 CTdgfQXOVVGmL1MgHWJJqEEVuygagZVtHncgIJFTus4PilOGGEr6T783xak5mw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715472509; a=rsa-sha256; cv=none; b=p40/2ZjN/0mCuI4Kz0YQM1iOTLAhz0dOuub+LY2Q4vgyqJ1dlE0Sb0e0JVwuFC/P2l0rpq 4WmrWhCbghqOkMw1RWA70D2pdGx96ASrjq7BquJ8r95JkMu7Qd+hFV/PuHZJtknrchDc6X p59cSR8GFa/0vmAxfNsjeWt/OiSPY79kXUW8hrzlwdSpwar3Cc7+U0nfM3UAVFXqYXFLV3 pVa9abaIbgdjN4rUo+yO0bEFn+3ewYPRUDa8dmekBXCYgFvRL82YnOjFWUHYC2RKqbDI01 VU77q+ePJRi8GO169ut6w/WDbm8RFOh0gjbxbHtzxv5vWPiovw4O7kGeXf24MA== 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=1715472509; 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=+tCjWBMDLeYRJyOSrR0s74hKQJuwtjmA3kZbxRsG30I=; b=HhYuYk1FEdTc0sbC6uIXAiGyKPFhWwXFRDPUUPwmhemxsbeGN/iig6/yJdmcl84TF51FLu ArFpEO6IIDdWESar0Jxzzy4NPWPO+UWdLKLb9rW0/crESUudHYKiiJV0fSQPZACXlNlzzY BvRsIk3RpaHPNUI5t44VKkNENwXG4Fa4vmGj1xp5hkvOzn8Rj3g47AOsmueTCciz2zukWp l3r/Qk3fPCfsetKs/IMGSmA6ufO3ETaZ6kCrrtymBqv5dO16XCwv+bydak2Sljlc9aGjKH vESoq3xDWjoT0qaFdzWn75Yd4xXZyOOroUqrGT44toyvlJpLNabs2qR0Ec6h8g== 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 4VcNHx3XWzzhWH; Sun, 12 May 2024 00:08:29 +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 44C08TbJ001880; Sun, 12 May 2024 00:08:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44C08ToO001877; Sun, 12 May 2024 00:08:29 GMT (envelope-from git) Date: Sun, 12 May 2024 00:08:29 GMT Message-Id: <202405120008.44C08ToO001877@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jake Freeland Subject: git: 109b7712c3cb - stable/14 - 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/14 X-Git-Reftype: branch X-Git-Commit: 109b7712c3cbf2746b75f334abc75c39c32bc0b0 Auto-Submitted: auto-generated The branch stable/14 has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=109b7712c3cbf2746b75f334abc75c39c32bc0b0 commit 109b7712c3cbf2746b75f334abc75c39c32bc0b0 Author: Jake Freeland AuthorDate: 2024-04-06 18:31:21 +0000 Commit: Jake Freeland CommitDate: 2024-05-11 23:57:44 +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 (cherry picked from commit 6a4616a529c1e387d87376e48ceb670eef8141e7) --- 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 9e860e7c80a5..23b3403fec4f 100644 --- a/sys/kern/kern_procctl.c +++ b/sys/kern/kern_procctl.c @@ -28,6 +28,8 @@ */ #include +#include "opt_ktrace.h" + #include #include #include @@ -543,6 +545,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 b1860bf23cf2..802231767762 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1907,8 +1907,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);