1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-30 08:19:09 +00:00

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
This commit is contained in:
Jake Freeland 2024-04-06 13:31:21 -05:00
parent 05296a0ff6
commit 6a4616a529
2 changed files with 10 additions and 2 deletions

View File

@ -27,6 +27,8 @@
* SUCH DAMAGE.
*/
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/_unrhdr.h>
#include <sys/systm.h>
@ -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 ||

View File

@ -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);