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/tty.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/tty.c')
-rw-r--r-- | sys/kern/tty.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 7d34873..8a043fd 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id: tty.c,v 1.105 1998/07/11 10:41:15 bde Exp $ + * $Id: tty.c,v 1.106 1998/08/19 04:01:00 bde Exp $ */ /*- @@ -90,6 +90,7 @@ #include <sys/signalvar.h> #include <sys/resourcevar.h> #include <sys/malloc.h> +#include <sys/filedesc.h> #if NSNP > 0 #include <sys/snoop.h> #endif @@ -230,6 +231,7 @@ ttyclose(tp) { int s; + funsetown(tp->t_sigio); s = spltty(); if (constty == tp) constty = NULL; @@ -756,6 +758,25 @@ ttioctl(tp, cmd, data, flag) *(int *)data = ttnread(tp); splx(s); break; + + case FIOSETOWN: + /* + * Policy -- Don't allow FIOSETOWN on someone else's + * controlling tty + */ + if (tp->t_session != NULL && !isctty(p, tp)) + return (ENOTTY); + + error = fsetown(*(int *)data, &tp->t_sigio); + if (error) + return (error); + break; + case FIOGETOWN: + if (tp->t_session != NULL && !isctty(p, tp)) + return (ENOTTY); + *(int *)data = fgetown(tp->t_sigio); + break; + case TIOCEXCL: /* set exclusive use of tty */ s = spltty(); SET(tp->t_state, TS_XCLUDE); @@ -2082,8 +2103,8 @@ ttwakeup(tp) if (tp->t_rsel.si_pid != 0) selwakeup(&tp->t_rsel); - if (ISSET(tp->t_state, TS_ASYNC)) - pgsignal(tp->t_pgrp, SIGIO, 1); + if (ISSET(tp->t_state, TS_ASYNC) && tp->t_sigio != NULL) + pgsigio(tp->t_sigio, SIGIO, (tp->t_session != NULL)); wakeup(TSA_HUP_OR_INPUT(tp)); } |