All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] tty_lock: undo the old tty_lock use on the ctty
@ 2012-05-03 21:21 Alan Cox
  2012-05-03 21:22 ` [PATCH 2/3] pty: Lock the devpts bits privately Alan Cox
  2012-05-03 21:24 ` [PATCH 3/3] tty_lock: Localise the lock Alan Cox
  0 siblings, 2 replies; 21+ messages in thread
From: Alan Cox @ 2012-05-03 21:21 UTC (permalink / raw)
  To: linux-kernel, linux-serial

From: Alan Cox <alan@linux.intel.com>

get_current_tty has its own consistent locking. That means a pile of the
tty lock cases are not needed. As get_current_tty also keeps a reference the
tty object lifetime means we can propogate the lock removal out.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/tty/tty_io.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)


diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index d939bd7..b425c79 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -855,10 +855,11 @@ void disassociate_ctty(int on_exit)
  */
 void no_tty(void)
 {
+	/* FIXME: Review locking here. The tty_lock never covered any race
+	   between a new association and proc_clear_tty but possible we need
+	   to protect against this anyway */
 	struct task_struct *tsk = current;
-	tty_lock();
 	disassociate_ctty(0);
-	tty_unlock();
 	proc_clear_tty(tsk);
 }
 
@@ -1800,6 +1801,9 @@ int tty_release(struct inode *inode, struct file *filp)
  *
  *	We cannot return driver and index like for the other nodes because
  *	devpts will not work then. It expects inodes to be from devpts FS.
+ *
+ *	We need to move to returning a refcounted object from all the lookup
+ *	paths including this one.
  */
 static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
 {
@@ -1816,6 +1820,7 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
 	/* noctty = 1; */
 	tty_kref_put(tty);
 	/* FIXME: we put a reference and return a TTY! */
+	/* This is only safe because the caller holds tty_mutex */
 	return tty;
 }
 


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2012-05-11 15:10 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-03 21:21 [PATCH 1/3] tty_lock: undo the old tty_lock use on the ctty Alan Cox
2012-05-03 21:22 ` [PATCH 2/3] pty: Lock the devpts bits privately Alan Cox
2012-05-08 18:18   ` H. Peter Anvin
2012-05-08 20:43     ` Alan Cox
2012-05-08 20:41       ` H. Peter Anvin
2012-05-03 21:24 ` [PATCH 3/3] tty_lock: Localise the lock Alan Cox
2012-05-04 20:48   ` Arnd Bergmann
2012-05-04 23:54   ` Greg KH
2012-05-04 23:55     ` Greg KH
2012-05-07 16:03   ` Sasha Levin
2012-05-07 16:03     ` Sasha Levin
2012-05-07 16:11     ` Alan Cox
2012-05-07 16:30       ` Sasha Levin
2012-05-07 16:42         ` Alan Cox
2012-05-07 17:00           ` Sasha Levin
2012-05-07 21:04             ` Jiri Slaby
2012-05-08 18:12               ` Sasha Levin
2012-05-11 10:40                 ` Sasha Levin
2012-05-11 14:52                   ` Greg KH
2012-05-11 15:09                     ` Sasha Levin
2012-05-11 15:09                       ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.