]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/process_policy.c
xnu-3789.60.24.tar.gz
[apple/xnu.git] / bsd / kern / process_policy.c
index ffbd70e98f78dcf63e91a09644dc961bcc255444..bcf69d7c8f589015827f5b4e30b4f6f5398b7da8 100644 (file)
@@ -164,9 +164,11 @@ process_policy(__unused struct proc *p, struct process_policy_args * uap, __unus
                                case PROC_POLICY_RUSAGE_DISK:
                                case PROC_POLICY_RUSAGE_NETWORK:
                                case PROC_POLICY_RUSAGE_POWER:
-                                       return(ENOTSUP);
+                                       error = ENOTSUP;
+                                       goto out;
                                default:
-                                       return(EINVAL);
+                                       error = EINVAL;
+                                       goto out;
                                case PROC_POLICY_RUSAGE_CPU:
                                        break;
                        }
@@ -243,6 +245,12 @@ handle_cpuuse(int action, user_addr_t attrp, proc_t proc, __unused uint64_t targ
        }
 #endif
 
+       // on macOS tasks can only set and clear their own CPU limits
+       if ((action == PROC_POLICY_ACTION_APPLY || action == PROC_POLICY_ACTION_RESTORE)
+            && proc != current_proc()) {
+               return (EPERM);
+       }
+
        switch (action) {
                case PROC_POLICY_ACTION_GET: 
                        error = proc_get_task_ruse_cpu(proc->task, &cpuattr.ppattr_cpu_attr,