Skip to contentSkip to conversation

UNIX98 pty indices leak

PATCH Vladimir B. Savkin 1 participant 1 message Jul 21, 2004 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hello!

I noticed that our PPPoE/PPtP access concentrator leaks pty devices. When all 4096 indices are leaked, there was need to reboot it.

The following patch fixes this problem (tested on 2.6.7-mm7, but applies cleanly to 2.6.8-rc2).

drivers/char/tty_io.c renamed from linux-2.6.7/drivers/char/tty_io.c +4 -3
@@ -1060,7 +1060,7 @@
 {
 	struct tty_struct *tty, *o_tty;
 	int	pty_master, tty_closing, o_tty_closing, do_sleep;
-	int	devpts_master;
+	int	devpts_master, devpts;
 	int	idx;
 	char	buf[64];
 	
@@ -1075,7 +1075,8 @@
 	idx = tty->index;
 	pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
 		      tty->driver->subtype == PTY_TYPE_MASTER);
-	devpts_master = pty_master && (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM);
+	devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
+	devpts_master = pty_master && devpts;
 	o_tty = tty->link;
 
 #ifdef TTY_PARANOIA_CHECK
@@ -1300,7 +1301,7 @@
 
 #ifdef CONFIG_UNIX98_PTYS
 	/* Make this pty number available for reallocation */
-	if (devpts_master) {
+	if (devpts) {
 		down(&allocated_ptys_lock);
 		idr_remove(&allocated_ptys, idx);
 		up(&allocated_ptys_lock);

~
:wq
With best regards,
Vladimir Savkin.