MCPcopy Create free account
hub / github.com/F-Stack/f-stack / p_cansched

Function p_cansched

freebsd/kern/kern_prot.c:1611–1637  ·  view source on GitHub ↗

- * 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 */

Source from the content-addressed store, hash-verified

1609 * References: td and p must be valid for the lifetime of the call
1610 */
1611int
1612p_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

Callers 7

protect_setchildFunction · 0.85
cpuset_whichFunction · 0.85
kern_sched_setparamFunction · 0.85
kern_sched_setschedulerFunction · 0.85
doniceFunction · 0.85
sys_rtprio_threadFunction · 0.85
sys_rtprioFunction · 0.85

Calls 5

prison_checkFunction · 0.85
mac_proc_check_schedFunction · 0.85
cr_canseeotheruidsFunction · 0.85
cr_canseeothergidsFunction · 0.85
priv_checkFunction · 0.70

Tested by

no test coverage detected