Messages in this thread Patch in this message | | | Date | Thu, 15 May 2008 20:27:03 +0400 | From | Oleg Nesterov <> | Subject | [PATCH] tty_check_change-avoid-taking-tasklist_lock-while-holding-tty-ctrl_lock-simplify |
| |
On 05/14, Oleg Nesterov wrote: > > The patch looks correct anyway, but perhaps tty_check_change() doesn't need > ->ctrl_lock at all? We don't dereference tty->pgrp.
IOW, I think the patch below makes sense.
With the previous patch tty->ctrl_lock buys nothing, it only protects the "task_pgrp(current) == tty->pgrp" check, but tty->pgrp can be changed right after spin_unlock_irqrestore(tty->ctrl_lock) anyway.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- HL/drivers/char/tty_io.c~TTY 2008-05-15 19:09:35.000000000 +0400 +++ HL/drivers/char/tty_io.c 2008-05-15 19:11:57.000000000 +0400 @@ -1199,27 +1199,21 @@ EXPORT_SYMBOL_GPL(tty_find_polling_drive * If we try to write to, or set the state of, a terminal and we're * not in the foreground, send a SIGTTOU. If the signal is blocked or * ignored, go ahead and perform the operation. (POSIX 7.2) - * - * Locking: ctrl_lock */ int tty_check_change(struct tty_struct *tty) { - unsigned long flags; int ret = 0; if (current->signal->tty != tty) return 0; - spin_lock_irqsave(&tty->ctrl_lock, flags); - if (!tty->pgrp) { printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n"); - goto out_unlock; + goto out; } if (task_pgrp(current) == tty->pgrp) - goto out_unlock; - spin_unlock_irqrestore(&tty->ctrl_lock, flags); + goto out; if (is_ignored(SIGTTOU)) goto out; if (is_current_pgrp_orphaned()) { @@ -1231,9 +1225,6 @@ int tty_check_change(struct tty_struct * ret = -ERESTARTSYS; out: return ret; -out_unlock: - spin_unlock_irqrestore(&tty->ctrl_lock, flags); - return ret; } EXPORT_SYMBOL(tty_check_change);
| |