diff options
author | mbr <mbr@FreeBSD.org> | 2006-09-30 22:51:05 +0000 |
---|---|---|
committer | mbr <mbr@FreeBSD.org> | 2006-09-30 22:51:05 +0000 |
commit | 7e18a1992866a2d0e102c79f2e23eafa78f0c921 (patch) | |
tree | 60d996046d02c16490cd1fca1b3bbd89ea171ad5 | |
parent | 684314301391fb018578a8411b1733848605293e (diff) | |
download | FreeBSD-src-7e18a1992866a2d0e102c79f2e23eafa78f0c921.zip FreeBSD-src-7e18a1992866a2d0e102c79f2e23eafa78f0c921.tar.gz |
Readd rev. 1.145 because of vfs bugs and races near revoke(). Until they
are fixed we can't free any slaves. Add a workaround to not to leak ptys
by number.
-rw-r--r-- | sys/kern/tty_pty.c | 18 |
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; |