Re: [PATCH]: disassociate tty locking fixups

From: Arjan van de Ven
Date: Sat Oct 14 2006 - 08:20:45 EST



> @@ -1364,14 +1366,16 @@ static void do_tty_hangup(void *data)
> p->signal->tty = NULL;
> if (!p->signal->leader)
> continue;
> + mutex_unlock(&tty_mutex);
> group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
> group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
> + mutex_lock(&tty_mutex);
> if (tty->pgrp > 0)
> p->signal->tty_old_pgrp = tty->pgrp;
> } while_each_task_pid(tty->session, PIDTYPE_SID, p);
> }
> read_unlock(&tasklist_lock);
> -
> + mutex_unlock(&tty_mutex);

Hi,

what is the lock ordering rules between tasklist_lock and tty_mutex?
In the code above you first take tty_mutex then tasklist_lock, and later
on you drop tty_mutex, with the result that you then have a
tasklist_lock -> tty_mutex order.

This can deadlock if someone gets in the middle with a
mutex_lock(&tty_mutex);
write_lock(&tasklist_lock);
....

in addition, are you sure you don't need to revalidate anything after
retaking the lock?

Greetings,
Arjan van de Ven

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/