]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] disassociate_ctty SMP fix
authorAndrew Morton <akpm@digeo.com>
Wed, 12 Feb 2003 05:06:21 +0000 (21:06 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 12 Feb 2003 05:06:21 +0000 (21:06 -0800)
Patch from Rik van Riel <riel@conectiva.com.br>

the following patch, against today's BK tree, fixes a small
SMP race in disassociate_ctty.  This function gets called
from do_exit, without the BKL held.

However, it sets the *tty variable before grabbing the bkl,
then makes decisions on what the variable was set to before
the lock was grabbed, despite the fact that another process
could modify its ->tty pointer in this same function.

drivers/char/tty_io.c

index 33a5eb9a6b2b864c49b7c744a3e379dae870cd39..533c7e76daba2ccb8fa7a399d471d1db69b01795 100644 (file)
@@ -578,7 +578,7 @@ EXPORT_SYMBOL(tty_hung_up_p);
  */
 void disassociate_ctty(int on_exit)
 {
-       struct tty_struct *tty = current->tty;
+       struct tty_struct *tty;
        struct task_struct *p;
        struct list_head *l;
        struct pid *pid;
@@ -586,6 +586,7 @@ void disassociate_ctty(int on_exit)
 
        lock_kernel();
 
+       tty = current->tty;
        if (tty) {
                tty_pgrp = tty->pgrp;
                if (on_exit && tty->driver.type != TTY_DRIVER_TYPE_PTY)