#include <kern/thread_call.h>
#include <kern/sched_prim.h>
#include <kern/assert.h>
+#include <sys/codesign.h>
+
#if CONFIG_DTRACE
/* Do not include dtrace.h, it redefines kmem_[alloc/free] */
extern void (*dtrace_fasttrap_exit_ptr)(proc_t);
ut = get_bsdthread_info(self);
/* If a core should be generated, notify crash reporter */
- if (hassigprop(WTERMSIG(rv), SA_CORE)) {
+ if (hassigprop(WTERMSIG(rv), SA_CORE) || ((p->p_csflags & CS_KILLED) != 0)) {
/*
* Workaround for processes checking up on PT_DENY_ATTACH:
* should be backed out post-Leopard (details in 5431025).
TAILQ_INIT(&child_proc->p_aio_doneq);
/* Inherit the parent flags for code sign */
- child_proc->p_csflags = parent_proc->p_csflags;
+ child_proc->p_csflags = (parent_proc->p_csflags & ~CS_KILLED);
/*
* All processes have work queue locks; cleaned up by
static void lctxinit(void);
#endif
+int cs_debug; /* declared further down in this file */
+
#if DEBUG
#define __PROC_INTERNAL_DEBUG 1
#endif
if ((pt->p_csflags & CS_VALID) == CS_VALID) { /* is currently valid */
pt->p_csflags &= ~CS_VALID; /* set invalid */
if ((pt->p_csflags & CS_KILL) == CS_KILL) {
+ pt->p_csflags |= CS_KILLED;
proc_unlock(pt);
+ if (cs_debug) {
+ printf("CODE SIGNING: marked invalid by pid %d: "
+ "p=%d[%s] honoring CS_KILL, final status 0x%x\n",
+ proc_selfpid(), pt->p_pid, pt->p_comm, pt->p_csflags);
+ }
psignal(pt, SIGKILL);
} else
proc_unlock(pt);
/* CS_KILL triggers us to send a kill signal. Nothing else. */
if (p->p_csflags & CS_KILL) {
+ p->p_csflags |= CS_KILLED;
proc_unlock(p);
if (cs_debug) {
printf("CODE SIGNING: cs_invalid_page(0x%llx): "
- "p=%d[%s] honoring CS_KILL\n",
- vaddr, p->p_pid, p->p_comm);
+ "p=%d[%s] honoring CS_KILL, final status 0x%x\n",
+ vaddr, p->p_pid, p->p_comm, p->p_csflags);
}
cs_procs_killed++;
psignal(p, SIGKILL);
cs_blob_size_max = (UInt32) blob->csb_mem_size;
}
- if (cs_debug) {
+ if (cs_debug > 1) {
proc_t p;
p = current_proc();
#define CS_KILL 0x0200 /* kill process if it becomes invalid */
#define CS_EXEC_SET_HARD 0x1000 /* set CS_HARD on any exec'ed process */
#define CS_EXEC_SET_KILL 0x2000 /* set CS_KILL on any exec'ed process */
+#define CS_KILLED 0x10000 /* was killed by kernel for invalidity */
/* csops operations */
#define CS_OPS_STATUS 0 /* return status */
-10.5.0
+10.6.0
# The first line of this file contains the master version number for the kernel.
# All other instances of the kernel version in xnu are derived from this file.