mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Oops tty layer -- 31-rc3 and 31-rc2-git10
@ 2009-07-14 23:47 Pete Clements
  2009-07-15  9:01 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Clements @ 2009-07-14 23:47 UTC (permalink / raw)
  To: linux-kernel

Fyi:
Getting the following oops on shutdown with 31-rc2-git10 and 31-rc3.
(x86 UP)

BUG: unable to handle kernel NULL pointer dereference at 00000004
IP: [<c10fe4d4>] tty_ldisc_wait_idle+0x74/0xe0
*pde = 00000000 
Oops: 0000 [#1] 
last sysfs file: 
Modules linked in: ipv6

Pid: 1954, comm: login Not tainted (2.6.31-rc3 #1) XPST450
EIP: 0060:[<c10fe4d4>] EFLAGS: 00010296 CPU: 0
EIP is at tty_ldisc_wait_idle+0x74/0xe0
EAX: 00000000 EBX: 000004e2 ECX: d7ba5df8 EDX: d7ba5dec
ESI: d78fac00 EDI: d78fac00 EBP: d7ba5df8 ESP: d7ba5dec
 DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
Process login (pid: 1954, ti=d7ba4000 task=d78ed1b0 task.ti=d7ba4000)
Stack:
 00000000 d78ed1b0 c1027870 c124184c c124184c d78fac14 d78fac00 d78fac00
<0> 00000000 c10fec5a 00000001 d78fad08 d78fad08 d78fac00 c10f7fc7 00000000
<0> 00000001 d7b850a0 00000000 d7854920 d78fac00 00000001 d7983584 c10f84d6
Call Trace:
 [<c1027870>] ? autoremove_wake_function+0x0/0x50
 [<c10fec5a>] ? tty_ldisc_hangup+0xda/0x190
 [<c10f7fc7>] ? do_tty_hangup+0x97/0x2b0
 [<c10f84d6>] ? disassociate_ctty+0x36/0x150
 [<c101922d>] ? do_exit+0x5dd/0x630
 [<c101ef2a>] ? recalc_sigpending+0xa/0x20
 [<c102172f>] ? dequeue_signal+0x2f/0x180
 [<c101040b>] ? pte_alloc_one+0x1b/0x50
 [<c10192aa>] ? do_group_exit+0x2a/0x80
 [<c1021be9>] ? get_signal_to_deliver+0x129/0x300
 [<c1001fe8>] ? do_notify_resume+0xb8/0x830
 [<c10124bd>] ? dequeue_task_fair+0x1d/0x170
 [<c1011999>] ? dequeue_task+0x69/0xc0
 [<c11bbfb3>] ? schedule+0x233/0x360
 [<c1018985>] ? do_wait+0x155/0x250
 [<c1013e30>] ? default_wake_function+0x0/0x10
 [<c1018b15>] ? sys_wait4+0x95/0xe0
 [<c1002d3a>] ? work_notifysig+0x13/0x19
Code: 00 89 44 24 08 89 6c 24 0c 89 6c 24 10 8d 76 00 8d bc 27 00 00 00 00 b8 4c 18 24 c1 b9 02 00 00 00 89 e2 e8 af 91 f2 ff 8b 46 20 <8b> 40 04 85 c0 74 2d 89 d8 e8 ee dc 0b 00 85 c0 89 c3 75 d8 89 
EIP: [<c10fe4d4>] tty_ldisc_wait_idle+0x74/0xe0 SS:ESP 0068:d7ba5dec
CR2: 0000000000000004
---[ end trace eb52b7270d368252 ]---
Fixing recursive fault but reboot is needed!

-- 
Pete Clements 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Oops tty layer -- 31-rc3 and 31-rc2-git10
  2009-07-14 23:47 Oops tty layer -- 31-rc3 and 31-rc2-git10 Pete Clements
@ 2009-07-15  9:01 ` Alan Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2009-07-15  9:01 UTC (permalink / raw)
  To: Pete Clements; +Cc: linux-kernel

On Tue, 14 Jul 2009 19:47:02 -0400 (EDT)
Pete Clements <clem@clem.clem-digital.net> wrote:

> Fyi:
> Getting the following oops on shutdown with 31-rc2-git10 and 31-rc3.
> (x86 UP)

Yep - testing a fix in -next at the moment.

--


tty: fix close/hangup race

From: Alan Cox <alan@linux.intel.com>

We can get a situation where a hangup occurs during or after a close. In
that case the ldisc gets disposed of by the close and the hangup then
explodes.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/char/tty_ldisc.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)


diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 913aa8d..5018e08 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -791,17 +791,20 @@ void tty_ldisc_hangup(struct tty_struct *tty)
 	 * N_TTY.
 	 */
 	if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
-		/* Avoid racing set_ldisc */
+		/* Avoid racing set_ldisc or tty_ldisc_release */
 		mutex_lock(&tty->ldisc_mutex);
-		/* Switch back to N_TTY */
-		tty_ldisc_halt(tty);
-		tty_ldisc_wait_idle(tty);
-		tty_ldisc_reinit(tty);
-		/* At this point we have a closed ldisc and we want to
-		   reopen it. We could defer this to the next open but
-		   it means auditing a lot of other paths so this is a FIXME */
-		WARN_ON(tty_ldisc_open(tty, tty->ldisc));
-		tty_ldisc_enable(tty);
+		if (tty->ldisc) {	/* Not yet closed */
+			/* Switch back to N_TTY */
+			tty_ldisc_halt(tty);
+			tty_ldisc_wait_idle(tty);
+			tty_ldisc_reinit(tty);
+			/* At this point we have a closed ldisc and we want to
+			   reopen it. We could defer this to the next open but
+			   it means auditing a lot of other paths so this is
+			   a FIXME */
+			WARN_ON(tty_ldisc_open(tty, tty->ldisc));
+			tty_ldisc_enable(tty);
+		}
 		mutex_unlock(&tty->ldisc_mutex);
 		tty_reset_termios(tty);
 	}
@@ -866,6 +869,7 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
 
 	tty_ldisc_wait_idle(tty);
 
+	mutex_lock(&tty->ldisc_mutex);
 	/*
 	 * Now kill off the ldisc
 	 */
@@ -876,6 +880,7 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
 
 	/* Ensure the next open requests the N_TTY ldisc */
 	tty_set_termios_ldisc(tty, N_TTY);
+	mutex_unlock(&tty->ldisc_mutex);
 
 	/* This will need doing differently if we need to lock */
 	if (o_tty)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-15  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-14 23:47 Oops tty layer -- 31-rc3 and 31-rc2-git10 Pete Clements
2009-07-15  9:01 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®