public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Tavis Ormandy <taviso@google.com>, Jeff Dike <jdike@addtoit.com>,
	Julien Tinnes <jln@google.com>, Matt Mackall <mpm@selenic.com>,
	stable <stable@kernel.org>
Subject: [PATCH 8/8] tty: fix race in tty_fasync
Date: Wed, 20 Jan 2010 15:50:03 -0800	[thread overview]
Message-ID: <1264031403-32239-8-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100120234759.GC32068@kroah.com>

We need to keep the lock held over the call to __f_setown() to
prevent a PID race.

Thanks to Al Viro for pointing out the problem, and to Travis for
making us look here in the first place.

Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Tavis Ormandy <taviso@google.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Julien Tinnes <jln@google.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/char/tty_io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index f15df40..c6f3b48 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1951,8 +1951,8 @@ static int tty_fasync(int fd, struct file *filp, int on)
 			pid = task_pid(current);
 			type = PIDTYPE_PID;
 		}
-		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 		retval = __f_setown(filp, pid, type, 0);
+		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 		if (retval)
 			goto out;
 	} else {
-- 
1.6.5.7


      parent reply	other threads:[~2010-01-20 23:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 23:47 [GIT PATCH] TTY patches for 2.6.33-rc4 Greg KH
2010-01-20 23:49 ` [PATCH 1/8] compat_ioctl: Supress "unknown cmd" message on serial /dev/console Greg Kroah-Hartman
2010-01-21  0:39   ` Arnd Bergmann
2010-01-20 23:49 ` [PATCH 2/8] nozomi: quick fix for the close/close bug Greg Kroah-Hartman
2010-01-20 23:49 ` [PATCH 3/8] serial: 8250_pnp: use wildcard for serial Wacom tablets Greg Kroah-Hartman
2010-01-20 23:49 ` [PATCH 4/8] serial-core: resume serial hardware with no_console_suspend Greg Kroah-Hartman
2010-01-20 23:50 ` [PATCH 5/8] serial: Fix crash if the minimum rate of the device is > 9600 baud Greg Kroah-Hartman
2010-01-20 23:50 ` [PATCH 6/8] serial: imx: bit &/| confusion Greg Kroah-Hartman
2010-01-21 13:34   ` Sascha Hauer
2010-01-20 23:50 ` [PATCH 7/8] serial: serial_cs: oxsemi quirk breaks resume Greg Kroah-Hartman
2010-01-20 23:50 ` Greg Kroah-Hartman [this message]

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=1264031403-32239-8-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=ebiederm@xmission.com \
    --cc=jdike@addtoit.com \
    --cc=jln@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=stable@kernel.org \
    --cc=taviso@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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