diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index c1f5daceb895..49ce1782e8dc 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -97,6 +97,18 @@ SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW, &kern_logsigexit, 0, "Log processes quitting on abnormal signals to syslog(3)"); +/* + * Policy -- Can ucred cr1 send SIGIO to process cr2? + * Should use cr_cansignal() once cr_cansignal() allows SIGIO and SIGURG + * in the right situations. + */ +#define CANSIGIO(cr1, cr2) \ + ((cr1)->cr_uid == 0 || \ + (cr1)->cr_ruid == (cr2)->cr_ruid || \ + (cr1)->cr_uid == (cr2)->cr_ruid || \ + (cr1)->cr_ruid == (cr2)->cr_uid || \ + (cr1)->cr_uid == (cr2)->cr_uid) + int sugid_coredump; SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, &sugid_coredump, 0, "Enable coredumping set user/group ID processes"); @@ -2064,8 +2076,7 @@ pgsigio(sigio, sig, checkctty) if (sigio->sio_pgid > 0) { PROC_LOCK(sigio->sio_proc); - if (cr_cansignal(sigio->sio_ucred, sigio->sio_proc, sig) - == 0) + if (CANSIGIO(sigio->sio_ucred, sigio->sio_proc->p_ucred)) psignal(sigio->sio_proc, sig); PROC_UNLOCK(sigio->sio_proc); } else if (sigio->sio_pgid < 0) { @@ -2073,7 +2084,7 @@ pgsigio(sigio, sig, checkctty) LIST_FOREACH(p, &sigio->sio_pgrp->pg_members, p_pglist) { PROC_LOCK(p); - if ((cr_cansignal(sigio->sio_ucred, p, sig) == 0) && + if (CANSIGIO(sigio->sio_ucred, p->p_ucred) && (checkctty == 0 || (p->p_flag & P_CONTROLT))) psignal(p, sig); PROC_UNLOCK(p);