summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/tty_pty.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 4afb803..2f1b2eb 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -184,7 +184,11 @@ static void
pty_maybe_destroy_slave(struct ptsc *pt)
{
- if (pt->pt_devc_open == 0 && pt->pt_devs_open == 0)
+ /*
+ * vfs bugs and complications near revoke() make
+ * it currently impossible to destroy struct cdev
+ */
+ if (0 && pt->pt_devc_open == 0 && pt->pt_devs_open == 0)
pty_destroy_slave(pt);
}
@@ -328,12 +332,18 @@ ptcopen(struct cdev *dev, int flag, int devtype, struct thread *td)
pt->pt_tty = ttyalloc();
pt->pt_tty->t_sc = pt;
dev->si_tty = pt->pt_tty;
- pty_create_slave(td->td_ucred, pt, minor(dev));
}
tp = dev->si_tty;
- if (tp->t_oproc)
- return (EIO);
+ if (tp->t_oproc) {
+ /*
+ * Only return if we have a non empty
+ * state to avoid leakage. Workaround for
+ * vfs bugs and complications near revoke().
+ */
+ if (tp->t_state != 0x0 || tp->t_refcnt > 1)
+ return (EIO);
+ }
tp->t_timeout = -1;
tp->t_oproc = ptsstart;
tp->t_stop = ptsstop;
OpenPOWER on IntegriCloud