diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2015-09-17 17:17:08 +0200 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-08 06:12:47 -0400 |
commit | 2e279b7d786ccbe8aa4345c1ec43bafab179b409 (patch) | |
tree | 150f08811a84c0bd1ff6b4c5398eeb10dbf0cfcd /drivers/tty | |
parent | 3e984ccc90f828efb6606b12c7097c958de0393d (diff) |
tty: fix data race in flush_to_ldisc
[ Upstream commit 7098296a362a96051fa120abf48f0095818b99cd ]
flush_to_ldisc reads port->itty and checks that it is not NULL,
concurrently release_tty sets port->itty to NULL. It is possible
that flush_to_ldisc loads port->itty once, ensures that it is
not NULL, but then reloads it again and uses. The second load
can already return NULL, which will cause a crash.
Use READ_ONCE to read port->itty.
The data race was found with KernelThreadSanitizer (KTSAN).
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_buffer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 6b9de83d297e..dc86638b19ce 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -443,7 +443,7 @@ static void flush_to_ldisc(struct work_struct *work) struct tty_struct *tty; struct tty_ldisc *disc; - tty = port->itty; + tty = READ_ONCE(port->itty); if (tty == NULL) return; |