All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "tty: fix data race in tty_ldisc_ref_wait()" has been added to the 4.9-stable tree
@ 2017-12-18 13:23 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-12-18 13:23 UTC (permalink / raw)
  To: dvyukov, alexander.levin, gnomes, gregkh, jslaby, peter
  Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    tty: fix data race in tty_ldisc_ref_wait()

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tty-fix-data-race-in-tty_ldisc_ref_wait.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From foo@baz Mon Dec 18 14:12:34 CET 2017
From: Dmitry Vyukov <dvyukov@google.com>
Date: Sat, 4 Mar 2017 13:46:12 +0100
Subject: tty: fix data race in tty_ldisc_ref_wait()

From: Dmitry Vyukov <dvyukov@google.com>


[ Upstream commit a4a3e061149f09c075f108b6f1cf04d9739a6bc2 ]

tty_ldisc_ref_wait() checks tty->ldisc under tty->ldisc_sem.
But if ldisc==NULL it releases them sem and reloads
tty->ldisc without holding the sem. This is wrong and
can lead to returning non-NULL ldisc without protection.

Don't reload tty->ldisc second time.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: syzkaller@googlegroups.com
Cc: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/tty/tty_ldisc.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -271,10 +271,13 @@ const struct file_operations tty_ldiscs_
 
 struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty)
 {
+	struct tty_ldisc *ld;
+
 	ldsem_down_read(&tty->ldisc_sem, MAX_SCHEDULE_TIMEOUT);
-	if (!tty->ldisc)
+	ld = tty->ldisc;
+	if (!ld)
 		ldsem_up_read(&tty->ldisc_sem);
-	return tty->ldisc;
+	return ld;
 }
 EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait);
 


Patches currently in stable-queue which might be from dvyukov@google.com are

queue-4.9/tty-fix-data-race-in-tty_ldisc_ref_wait.patch
queue-4.9/kvm-nvmx-do-not-warn-when-msr-bitmap-address-is-not-backed.patch
queue-4.9/userfaultfd-shmem-__do_fault-requires-vm_fault_nopage.patch
queue-4.9/tty-don-t-panic-on-oom-in-tty_set_ldisc.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-18 13:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-18 13:23 Patch "tty: fix data race in tty_ldisc_ref_wait()" has been added to the 4.9-stable tree gregkh

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.