diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-07-11 22:48:52 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-07-11 22:48:52 +0000 |
commit | 44585037d4fd87ec65a16e801990bcb3182156cd (patch) | |
tree | ee294c3a6df9ed96987cba4ffd4d625c1fc531f3 /sys/kern/tty.c | |
parent | 19af39a209e72e0c23a3dd8bf77be4bf8106f7ba (diff) |
Make sure to protect ttypend with spltty all the time.
Implemented with paranoia.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r-- | sys/kern/tty.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 4092140d961..be858982f4f 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.53 2002/07/03 21:19:08 miod Exp $ */ +/* $OpenBSD: tty.c,v 1.54 2002/07/11 22:48:51 art Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -236,6 +236,7 @@ ttyinput(c, tp) register int iflag, lflag; register u_char *cc; int i, error; + int s; add_tty_randomness(tp->t_dev << 8 | c); /* @@ -243,12 +244,15 @@ ttyinput(c, tp) */ if (!ISSET(tp->t_cflag, CREAD)) return (0); + /* * If input is pending take it first. */ lflag = tp->t_lflag; + s = spltty(); if (ISSET(lflag, PENDIN)) ttypend(tp); + splx(s); /* * Gather stats. */ @@ -779,7 +783,9 @@ ttioctl(tp, cmd, data, flag, p) case FIONBIO: /* set/clear non-blocking i/o */ break; /* XXX: delete. */ case FIONREAD: /* get # bytes to read */ + s = spltty(); *(int *)data = ttnread(tp); + splx(s); break; case TIOCEXCL: /* set exclusive use of tty */ s = spltty(); @@ -1101,8 +1107,11 @@ filt_ttyread(struct knote *kn, long hint) { dev_t dev = (dev_t)((u_long)kn->kn_hook); struct tty *tp = (*cdevsw[major(dev)].d_tty)(dev); + int s; + s = spltty(); kn->kn_data = ttnread(tp); + splx(s); if (!ISSET(tp->t_state, CLOCAL) && !ISSET(tp->t_state, TS_CARR_ON)) { kn->kn_flags |= EV_EOF; return (1); @@ -1139,6 +1148,8 @@ ttnread(tp) { int nread; + splassert(IPL_TTY); + if (ISSET(tp->t_lflag, PENDIN)) ttypend(tp); nread = tp->t_canq.c_cc; |