]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/mach_process.c
xnu-2050.7.9.tar.gz
[apple/xnu.git] / bsd / kern / mach_process.c
index 0df8a49c8dccbb1d297675232e310feb97688d65..1a5cac88f387b48a9f0f6d5d4d9ed2d350b3e501 100644 (file)
@@ -94,6 +94,8 @@
 
 #include <vm/vm_protos.h>              /* cs_allow_invalid() */
 
+#include <pexpert/pexpert.h>
+
 /* XXX ken/bsd_kern.c - prototype should be in common header */
 int get_task_userstop(task_t);
 
@@ -164,8 +166,10 @@ ptrace(struct proc *p, struct ptrace_args *uap, int32_t *retval)
                struct proc *pproc=proc_find(p->p_oppid);
                proc_unlock(p);
                cs_allow_invalid(p);
-               cs_allow_invalid(pproc);
-               proc_rele(pproc);
+               if(pproc) {
+                       cs_allow_invalid(pproc);
+                       proc_rele(pproc);
+               }
                return(0);
        }
        if (uap->req == PT_SIGEXC) {
@@ -309,6 +313,11 @@ ptrace(struct proc *p, struct ptrace_args *uap, int32_t *retval)
                 *      is resumed by adding NSIG to p_cursig. [see issig]
                 */
                proc_unlock(t);
+#if NOTYET
+               error = mac_proc_check_signal(p, t, SIGKILL);
+               if (0 != error)
+                       goto resume;
+#endif
                psignal(t, SIGKILL);
                goto resume;
 
@@ -321,14 +330,10 @@ ptrace(struct proc *p, struct ptrace_args *uap, int32_t *retval)
                        goto out;
                }
 
+               /* force use of Mach SPIs (and task_for_pid security checks) to adjust PC */
                if (uap->addr != (user_addr_t)1) {
-#if defined(ppc)
-#define ALIGNED(addr,size)     (((unsigned)(addr)&((size)-1))==0)
-                       if (!ALIGNED((int)uap->addr, sizeof(int)))
-                               return (ERESTART);
-#undef         ALIGNED
-#endif
-                       thread_setentrypoint(th_act, uap->addr);
+                       error = ENOTSUP;
+                       goto out;
                }
 
                if ((unsigned)uap->data >= NSIG) {
@@ -342,8 +347,15 @@ ptrace(struct proc *p, struct ptrace_args *uap, int32_t *retval)
 
                if (uap->req == PT_STEP) {
                        /*
-                        * set trace bit
+                        * set trace bit 
+                        * we use sending SIGSTOP as a comparable security check.
                         */
+#if NOTYET
+                       error = mac_proc_check_signal(p, t, SIGSTOP);
+                       if (0 != error) {
+                               goto out;
+                       }
+#endif
                        if (thread_setsinglestep(th_act, 1) != KERN_SUCCESS) {
                                error = ENOTSUP;
                                goto out;
@@ -351,7 +363,14 @@ ptrace(struct proc *p, struct ptrace_args *uap, int32_t *retval)
                } else {
                        /*
                         * clear trace bit if on
+                        * we use sending SIGCONT as a comparable security check.
                         */
+#if NOTYET
+                       error = mac_proc_check_signal(p, t, SIGCONT);
+                       if (0 != error) {
+                               goto out;
+                       }
+#endif
                        if (thread_setsinglestep(th_act, 0) != KERN_SUCCESS) {
                                error = ENOTSUP;
                                goto out;
@@ -434,7 +453,7 @@ cantrace(proc_t cur_procp, kauth_cred_t creds, proc_t traced_procp, int *errp)
         *      (3) it's not owned by you, or is set-id on exec
         *          (unless you're root).
         */
-       if ((creds->cr_ruid != proc_ucred(traced_procp)->cr_ruid ||
+       if ((kauth_cred_getruid(creds) != kauth_cred_getruid(proc_ucred(traced_procp)) ||
                ISSET(traced_procp->p_flag, P_SUGID)) &&
                (my_err = suser(creds, &cur_procp->p_acflag)) != 0) {
                *errp = my_err;