diff options
author | truckman <truckman@FreeBSD.org> | 1998-11-11 10:04:13 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 1998-11-11 10:04:13 +0000 |
commit | de184682fa22833c7b18a96a136bc031ae786434 (patch) | |
tree | b9b62a0e361f25bc4ed8f9636cce5f2fd2f12423 /sys/kern/subr_log.c | |
parent | 225b2f25416b4a11b425250105d4acbfc5bd5638 (diff) | |
download | FreeBSD-src-de184682fa22833c7b18a96a136bc031ae786434.zip FreeBSD-src-de184682fa22833c7b18a96a136bc031ae786434.tar.gz |
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
Diffstat (limited to 'sys/kern/subr_log.c')
-rw-r--r-- | sys/kern/subr_log.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 80193d4..01d8c4e 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)subr_log.c 8.1 (Berkeley) 6/10/93 - * $Id: subr_log.c,v 1.29 1998/05/28 09:30:20 phk Exp $ + * $Id: subr_log.c,v 1.30 1998/06/07 17:11:38 dfr Exp $ */ /* @@ -51,6 +51,7 @@ #include <sys/signalvar.h> #include <sys/kernel.h> #include <sys/poll.h> +#include <sys/filedesc.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ @@ -75,7 +76,7 @@ static struct cdevsw log_cdevsw = static struct logsoftc { int sc_state; /* see above for possibilities */ struct selinfo sc_selp; /* process waiting on select call */ - int sc_pgid; /* process/group for async I/O */ + struct sigio *sc_sigio; /* information for SIGIO */ } logsoftc; int log_open; /* also used in log() */ @@ -90,7 +91,7 @@ logopen(dev, flags, mode, p) if (log_open) return (EBUSY); log_open = 1; - logsoftc.sc_pgid = p->p_pid; /* signal process only */ + fsetown(p->p_pid, &logsoftc.sc_sigio); /* signal process only */ return (0); } @@ -104,6 +105,7 @@ logclose(dev, flag, mode, p) log_open = 0; logsoftc.sc_state = 0; + funsetown(logsoftc.sc_sigio); return (0); } @@ -183,12 +185,8 @@ logwakeup() if (!log_open) return; selwakeup(&logsoftc.sc_selp); - if (logsoftc.sc_state & LOG_ASYNC) { - if (logsoftc.sc_pgid < 0) - gsignal(-logsoftc.sc_pgid, SIGIO); - else if ((p = pfind(logsoftc.sc_pgid))) - psignal(p, SIGIO); - } + if ((logsoftc.sc_state & LOG_ASYNC) && logsoftc.sc_sigio != NULL) + pgsigio(logsoftc.sc_sigio, SIGIO, 0); if (logsoftc.sc_state & LOG_RDWAIT) { wakeup((caddr_t)msgbufp); logsoftc.sc_state &= ~LOG_RDWAIT; @@ -229,12 +227,20 @@ logioctl(dev, com, data, flag, p) logsoftc.sc_state &= ~LOG_ASYNC; break; - case TIOCSPGRP: - logsoftc.sc_pgid = *(int *)data; + case FIOSETOWN: + return (fsetown(*(int *)data, &logsoftc.sc_sigio)); + + case FIOGETOWN: + *(int *)data = fgetown(logsoftc.sc_sigio); break; + /* This is deprecated, FIOSETOWN should be used instead. */ + case TIOCSPGRP: + return (fsetown(-(*(int *)data), &logsoftc.sc_sigio)); + + /* This is deprecated, FIOGETOWN should be used instead */ case TIOCGPGRP: - *(int *)data = logsoftc.sc_pgid; + *(int *)data = -fgetown(logsoftc.sc_sigio); break; default: |