]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kern_sig.c
xnu-792.6.76.tar.gz
[apple/xnu.git] / bsd / kern / kern_sig.c
index 6313188a9c24281c3678823e1bb331aaf0ae3ee5..9b42ea1e2b92a2b7cf5ea5ffea3a70a1ce4d0cc2 100644 (file)
@@ -1128,7 +1128,7 @@ kill(struct proc *cp, struct kill_args *uap, __unused register_t *retval)
                return (EINVAL);
        if (uap->pid > 0) {
                /* kill single process */
-               if ((p = pfind(uap->pid)) == NULL) {
+               if ((p = proc_findref(uap->pid)) == NULL) {
                        if ((p = pzfind(uap->pid)) != NULL) {
                                /*
                                 * IEEE Std 1003.1-2001: return success
@@ -1139,10 +1139,13 @@ kill(struct proc *cp, struct kill_args *uap, __unused register_t *retval)
                        return (ESRCH);
                }
                AUDIT_ARG(process, p);
-               if (!cansignal(cp, uc, p, uap->signum))
-                       return (EPERM);
+               if (!cansignal(cp, uc, p, uap->signum)) {
+                       proc_dropref(p);
+                       return(EPERM);
+               }
                if (uap->signum)
                        psignal(p, uap->signum);
+               proc_dropref(p);
                return (0);
        }
        switch (uap->pid) {