FreeBSD/sys/kern/kern_prot.c
/*-
 * 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
 */
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
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
int
p_cansched(struct thread *td, struct proc *p)
{
	int error;
	KASSERT(td == curthread, ("%s: td not curthread", __func__));
	PROC_LOCK_ASSERT(p, MA_OWNED);
	if (td->td_proc == p)
		return (0);
	if ((error = prison_check(td->td_ucred, p->p_ucred)))
		return (error);
#ifdef MAC
	if ((error = mac_proc_check_sched(td->td_ucred, p)))
		return (error);
#endif
	if ((error = cr_seeotheruids(td->td_ucred, p->p_ucred)))
		return (error);
	if ((error = cr_seeothergids(td->td_ucred, p->p_ucred)))
		return (error);
	if (td->td_ucred->cr_ruid != p->p_ucred->cr_ruid &&
	    td->td_ucred->cr_uid != p->p_ucred->cr_ruid) {
		error = priv_check(td, PRIV_SCHED_DIFFCRED);
		if (error)
			return (error);
	}
	return (0);
}
int p_cansched ( struct thread * td , struct proc * p ) { int error ; KASSERT ( td == curthread , ( " " , __func__ ) ) ; PROC_LOCK_ASSERT ( p , MA_OWNED ) ; if ( td -> td_proc == p ) return ( 0 ) ; if ( ( error = prison_check ( td -> td_ucred , p -> p_ucred ) ) ) return ( error ) ; #ifdef MAC if ( ( error = mac_proc_check_sched ( td -> td_ucred , p ) ) ) return ( error ) ; #endif if ( ( error = cr_seeotheruids ( td -> td_ucred , p -> p_ucred ) ) ) return ( error ) ; if ( ( error = cr_seeothergids ( td -> td_ucred , p -> p_ucred ) ) ) return ( error ) ; if ( td -> td_ucred -> cr_ruid != p -> p_ucred -> cr_ruid && td -> td_ucred -> cr_uid != p -> p_ucred -> cr_ruid ) { error = priv_check ( td , PRIV_SCHED_DIFFCRED ) ; if ( error ) return ( error ) ; } return ( 0 ) ; }
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.
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 .