mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: Prarit Bhargava <prarit@redhat.com>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH]: disassociate tty locking fixups
Date: Sat, 14 Oct 2006 14:20:24 +0200	[thread overview]
Message-ID: <1160828425.15683.16.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <20061014112218.30218.93267.sendpatchset@prarit.boston.redhat.com>


> @@ -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


  reply	other threads:[~2006-10-14 12:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-14 11:22 Prarit Bhargava
2006-10-14 12:20 ` Arjan van de Ven [this message]
2006-10-14 12:55 ` Alan Cox
2006-10-14 15:06   ` Prarit Bhargava
2006-10-14 16:29     ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1160828425.15683.16.camel@laptopd505.fenrus.org \
    --to=arjan@infradead.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prarit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®