aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>1998-11-11 10:04:13 +0000
committerDon Lewis <truckman@FreeBSD.org>1998-11-11 10:04:13 +0000
commit831d27a9f56da38cf007714c169d208e7b9739be (patch)
tree2bce7c99fd05ca07a117966c4c41f2f544ef20f3 /sys/kern/kern_sig.c
parent21ffb6774a08602e1208977da6c5a652d85d32b6 (diff)
downloadsrc-831d27a9f56da38cf007714c169d208e7b9739be.tar.gz
src-831d27a9f56da38cf007714c169d208e7b9739be.zip
Installed the second patch attached to kern/7899 with some changes suggested
by bde, a few other tweaks to get the patch to apply cleanly again and some improvements to the comments. This change closes some fairly minor security holes associated with F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN had on tty devices. For more details, see the description on the PR. Because this patch increases the size of the proc and pgrp structures, it is necessary to re-install the includes and recompile libkvm, the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w. PR: kern/7899 Reviewed by: bde, elvind
Notes
Notes: svn path=/head/; revision=41086
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 290917ac4a10..29baceed4afb 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
- * $Id: kern_sig.c,v 1.47 1998/09/14 23:25:18 jdp Exp $
+ * $Id: kern_sig.c,v 1.48 1998/10/21 16:31:38 jdp Exp $
*/
#include "opt_compat.h"
@@ -86,6 +86,16 @@ SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW, &kern_logsigexit, 0,
(pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \
((signum) == SIGCONT && (q)->p_session == (p)->p_session))
+/*
+ * Policy -- Can real uid ruid with ucred uc send a signal to process q?
+ */
+#define CANSIGIO(ruid, uc, q) \
+ ((uc)->cr_uid == 0 || \
+ (ruid) == (q)->p_cred->p_ruid || \
+ (uc)->cr_uid == (q)->p_cred->p_ruid || \
+ (ruid) == (q)->p_ucred->cr_uid || \
+ (uc)->cr_uid == (q)->p_ucred->cr_uid)
+
int sugid_coredump;
SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, &sugid_coredump, 0, "");
@@ -1344,3 +1354,30 @@ nosys(p, args)
psignal(p, SIGSYS);
return (EINVAL);
}
+
+/*
+ * Send a signal to a SIGIO or SIGURG to a process or process group using
+ * stored credentials rather than those of the current process.
+ */
+void
+pgsigio(sigio, signum, checkctty)
+ struct sigio *sigio;
+ int signum, checkctty;
+{
+ if (sigio == NULL)
+ return;
+
+ if (sigio->sio_pgid > 0) {
+ if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred,
+ sigio->sio_proc))
+ psignal(sigio->sio_proc, signum);
+ } else if (sigio->sio_pgid < 0) {
+ struct proc *p;
+
+ for (p = sigio->sio_pgrp->pg_members.lh_first; p != NULL;
+ p = p->p_pglist.le_next)
+ if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, p) &&
+ (checkctty == 0 || (p->p_flag & P_CONTROLT)))
+ psignal(p, signum);
+ }
+}