FreeBSD/sys/kern/kern_prot.c
/*-
 * Determine whether cred may deliver the specified signal to proc.
 * Returns: 0 for permitted, an errno value otherwise.
 * Locks: A lock must be held for proc.
 * References: cred and proc must be valid for the lifetime of the call.
 */
Determine whether cred may deliver the specified signal to proc.
Returns: 0 for permitted, an errno value otherwise.
Locks: A lock must be held for proc.
References: cred and proc must be valid for the lifetime of the call.
Determine whether cred may deliver the specified signal to proc . Returns : 0 for permitted an errno value otherwise . Locks : A lock must be held for proc . References : cred and proc must be valid for the lifetime of the call .
int
cr_cansignal(struct ucred *cred, struct proc *proc, int signum)
{
	int error;
	PROC_LOCK_ASSERT(proc, MA_OWNED);
	error = prison_check(cred, proc->p_ucred);
	if (error)
		return (error);
#ifdef MAC
	if ((error = mac_proc_check_signal(cred, proc, signum)))
		return (error);
#endif
	if ((error = cr_seeotheruids(cred, proc->p_ucred)))
		return (error);
	if ((error = cr_seeothergids(cred, proc->p_ucred)))
		return (error);
	if (conservative_signals && (proc->p_flag & P_SUGID)) {
		switch (signum) {
		case 0:
		case SIGKILL:
		case SIGINT:
		case SIGTERM:
		case SIGALRM:
		case SIGSTOP:
		case SIGTTIN:
		case SIGTTOU:
		case SIGTSTP:
		case SIGHUP:
		case SIGUSR1:
		case SIGUSR2:
			break;
		default:
			error = priv_check_cred(cred, PRIV_SIGNAL_SUGID, 0);
			if (error)
				return (error);
		}
	}
	if (cred->cr_ruid != proc->p_ucred->cr_ruid &&
	    cred->cr_ruid != proc->p_ucred->cr_svuid &&
	    cred->cr_uid != proc->p_ucred->cr_ruid &&
	    cred->cr_uid != proc->p_ucred->cr_svuid) {
		error = priv_check_cred(cred, PRIV_SIGNAL_DIFFCRED, 0);
		if (error)
			return (error);
	}
	return (0);
}
int cr_cansignal ( struct ucred * cred , struct proc * proc , int signum ) { int error ; PROC_LOCK_ASSERT ( proc , MA_OWNED ) ; error = prison_check ( cred , proc -> p_ucred ) ; if ( error ) return ( error ) ; #ifdef MAC if ( ( error = mac_proc_check_signal ( cred , proc , signum ) ) ) return ( error ) ; #endif if ( ( error = cr_seeotheruids ( cred , proc -> p_ucred ) ) ) return ( error ) ; if ( ( error = cr_seeothergids ( cred , proc -> p_ucred ) ) ) return ( error ) ; if ( conservative_signals && ( proc -> p_flag & P_SUGID ) ) { switch ( signum ) { case 0 : case SIGKILL : case SIGINT : case SIGTERM : case SIGALRM : case SIGSTOP : case SIGTTIN : case SIGTTOU : case SIGTSTP : case SIGHUP : case SIGUSR1 : case SIGUSR2 : break ; default : error = priv_check_cred ( cred , PRIV_SIGNAL_SUGID , 0 ) ; if ( error ) return ( error ) ; } } if ( cred -> cr_ruid != proc -> p_ucred -> cr_ruid && cred -> cr_ruid != proc -> p_ucred -> cr_svuid && cred -> cr_uid != proc -> p_ucred -> cr_ruid && cred -> cr_uid != proc -> p_ucred -> cr_svuid ) { error = priv_check_cred ( cred , PRIV_SIGNAL_DIFFCRED , 0 ) ; if ( error ) return ( error ) ; } return ( 0 ) ; }
Determine whether cred may deliver the specified signal to proc.
Determine whether cred may deliver the specified signal to proc .
/*
	 * Jail semantics limit the scope of signalling to proc in the
	 * same jail as cred, if cred is in jail.
	 */ /*
	 * UNIX signal semantics depend on the status of the P_SUGID
	 * bit on the target process.  If the bit is set, then additional
	 * restrictions are placed on the set of available signals.
	 */ /*
			 * Generally, permit job and terminal control
			 * signals.
			 */ /* Not permitted without privilege. */ /*
	 * Generally, the target credential's ruid or svuid must match the
	 * subject credential's ruid or euid.
	 */