Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_cpuset.c
Show First 20 Lines • Show All 1,249 Lines • ▼ Show 20 Lines | cpuset_setproc(pid_t pid, struct cpuset *set, cpuset_t *mask, | ||||
} | } | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
/* | /* | ||||
* If we're changing roots and the root set is what has been specified | * If we're changing roots and the root set is what has been specified | ||||
* as the parent, then we'll check if the process was previously using | * as the parent, then we'll check if the process was previously using | ||||
* the root set and, if it wasn't, create a new base with the process's | * the root set and, if it wasn't, create a new base with the process's | ||||
* mask applied to it. | * mask applied to it. | ||||
* | |||||
* If the new root is incompatible with the existing mask, then we allow | |||||
* the process to take on the new root if and only if they have | |||||
* privilege to widen their mask anyways. Unprivileged processes get | |||||
* rejected with EDEADLK. | |||||
*/ | */ | ||||
if (set != NULL && rebase && nroot != tdroot) { | if (set != NULL && rebase && nroot != tdroot) { | ||||
cpusetid_t base_id, root_id; | cpusetid_t base_id, root_id; | ||||
root_id = td->td_ucred->cr_prison->pr_cpuset->cs_id; | root_id = td->td_ucred->cr_prison->pr_cpuset->cs_id; | ||||
base_id = cpuset_getbase(td->td_cpuset)->cs_id; | base_id = cpuset_getbase(td->td_cpuset)->cs_id; | ||||
if (base_id != root_id) { | if (base_id != root_id) { | ||||
error = cpuset_setproc_newbase(td, set, nroot, &base, | error = cpuset_setproc_newbase(td, set, nroot, &base, | ||||
&freelist, &domainlist); | &freelist, &domainlist); | ||||
if (error == EDEADLK && | |||||
priv_check(td, PRIV_SCHED_CPUSET) == 0) | |||||
error = 0; | |||||
if (error != 0) | if (error != 0) | ||||
goto unlock_out; | goto unlock_out; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Now that the appropriate locks are held and we have enough cpusets, | * Now that the appropriate locks are held and we have enough cpusets, | ||||
* make sure the operation will succeed before applying changes. The | * make sure the operation will succeed before applying changes. The | ||||
▲ Show 20 Lines • Show All 1,166 Lines • Show Last 20 Lines |