From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] pty: Fix lock inversion
Date: Mon, 28 May 2012 10:49:10 +0100 [thread overview]
Message-ID: <20120528094848.3001.48296.stgit@bob.linux.org.uk> (raw)
In-Reply-To: <20120528094741.3001.29866.stgit@bob.linux.org.uk>
From: Alan Cox <alan@linux.intel.com>
The ptmx_open path takes the tty and devpts locks in the wrong order
because tty_init_dev locks and returns a locked tty. As far as I can tell
this is actually safe anyway because the tty being returned is new so
nobody can get a reference to lock it at this point.
However we don't even need the devpts lock at this point, it's only held as
a byproduct of the way the locks were pushed down.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/tty/pty.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 59af394..65c7c62 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -633,7 +633,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
mutex_unlock(&devpts_mutex);
mutex_lock(&tty_mutex);
- mutex_lock(&devpts_mutex);
tty = tty_init_dev(ptm_driver, index);
if (IS_ERR(tty)) {
@@ -643,7 +642,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
/* The tty returned here is locked so we can safely
drop the mutex */
- mutex_unlock(&devpts_mutex);
mutex_unlock(&tty_mutex);
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
next prev parent reply other threads:[~2012-05-28 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-28 9:48 [PATCH 0/2] tty changes for the locking warnings Alan Cox
2012-05-28 9:49 ` Alan Cox [this message]
2012-05-28 9:49 ` [PATCH 2/2] tty: fix ldisc lock inversion trace Alan Cox
2012-05-28 11:29 ` [PATCH 0/2] tty changes for the locking warnings Greg KH
2012-05-28 12:13 ` Alan Cox
2012-05-29 9:32 ` Greg KH
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=20120528094848.3001.48296.stgit@bob.linux.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome