Commit 01ffc65c authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] disassociate_ctty SMP fix

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.
parent 40095952
...@@ -578,7 +578,7 @@ EXPORT_SYMBOL(tty_hung_up_p); ...@@ -578,7 +578,7 @@ EXPORT_SYMBOL(tty_hung_up_p);
*/ */
void disassociate_ctty(int on_exit) void disassociate_ctty(int on_exit)
{ {
struct tty_struct *tty = current->tty; struct tty_struct *tty;
struct task_struct *p; struct task_struct *p;
struct list_head *l; struct list_head *l;
struct pid *pid; struct pid *pid;
...@@ -586,6 +586,7 @@ void disassociate_ctty(int on_exit) ...@@ -586,6 +586,7 @@ void disassociate_ctty(int on_exit)
lock_kernel(); lock_kernel();
tty = current->tty;
if (tty) { if (tty) {
tty_pgrp = tty->pgrp; tty_pgrp = tty->pgrp;
if (on_exit && tty->driver.type != TTY_DRIVER_TYPE_PTY) if (on_exit && tty->driver.type != TTY_DRIVER_TYPE_PTY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment