summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-01-25 16:47:20 +0000
committerkib <kib@FreeBSD.org>2016-01-25 16:47:20 +0000
commit8d218f7844b26d40a38d2b850b787d05aa3cdce0 (patch)
tree4a4dad63be36d33fe77cb756acaf4bea8d00340a /sys/kern
parent1c17300d1dcdf3d060b9ffb3d59ac06094bd936f (diff)
downloadFreeBSD-src-8d218f7844b26d40a38d2b850b787d05aa3cdce0.zip
FreeBSD-src-8d218f7844b26d40a38d2b850b787d05aa3cdce0.tar.gz
Don't allow opening the callout device when the callin device is already
open (in disguise as the console device). The only allowed combination was supposed to be the callin device with the console. Fix the assertion in ttydev_close() that was meant to detect this (it only detected all 3 devices being open). Assert this in ttydev_open() too. Submitted by: bde MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/tty.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 168157b..9c08b93 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -263,10 +263,10 @@ ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
/*
* Make sure the "tty" and "cua" device cannot be opened at the
- * same time.
+ * same time. The console is a "tty" device.
*/
if (TTY_CALLOUT(tp, dev)) {
- if (tp->t_flags & TF_OPENED_IN) {
+ if (tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) {
error = EBUSY;
goto done;
}
@@ -319,6 +319,8 @@ ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
tp->t_flags |= TF_OPENED_OUT;
else
tp->t_flags |= TF_OPENED_IN;
+ MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
+ (tp->t_flags & TF_OPENED_OUT) == 0);
done: tp->t_flags &= ~TF_OPENCLOSE;
cv_broadcast(&tp->t_dcdwait);
@@ -338,7 +340,8 @@ ttydev_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
* Don't actually close the device if it is being used as the
* console.
*/
- MPASS((tp->t_flags & TF_OPENED) != TF_OPENED);
+ MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
+ (tp->t_flags & TF_OPENED_OUT) == 0);
if (dev == dev_console)
tp->t_flags &= ~TF_OPENED_CONS;
else
OpenPOWER on IntegriCloud