- * Determine whether td may reschedule p. * Returns: 0 for permitted, an errno value otherwise * Locks: Sufficient locks to protect various components of td and p * must be held. td must be curthread, and a lock must * be held for p. * References: td and p must be valid for the lifetime of the call */
| 1609 | * References: td and p must be valid for the lifetime of the call |
| 1610 | */ |
| 1611 | int |
| 1612 | p_cansched(struct thread *td, struct proc *p) |
| 1613 | { |
| 1614 | int error; |
| 1615 | |
| 1616 | KASSERT(td == curthread, ("%s: td not curthread", __func__)); |
| 1617 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 1618 | if (td->td_proc == p) |
| 1619 | return (0); |
| 1620 | if ((error = prison_check(td->td_ucred, p->p_ucred))) |
| 1621 | return (error); |
| 1622 | #ifdef MAC |
| 1623 | if ((error = mac_proc_check_sched(td->td_ucred, p))) |
| 1624 | return (error); |
| 1625 | #endif |
| 1626 | if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) |
| 1627 | return (error); |
| 1628 | if ((error = cr_canseeothergids(td->td_ucred, p->p_ucred))) |
| 1629 | return (error); |
| 1630 | if (td->td_ucred->cr_ruid != p->p_ucred->cr_ruid && |
| 1631 | td->td_ucred->cr_uid != p->p_ucred->cr_ruid) { |
| 1632 | error = priv_check(td, PRIV_SCHED_DIFFCRED); |
| 1633 | if (error) |
| 1634 | return (error); |
| 1635 | } |
| 1636 | return (0); |
| 1637 | } |
| 1638 | |
| 1639 | /* |
| 1640 | * Handle getting or setting the prison's unprivileged_proc_debug |
no test coverage detected