diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2015-09-17 11:17:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-04 14:03:40 -0400 |
commit | 7098296a362a96051fa120abf48f0095818b99cd (patch) | |
tree | d5faab1ed808c7fc3d55be88d431452b43e1e63e | |
parent | e81107d4c6bd098878af9796b24edc8d4a9524fd (diff) |
tty: fix data race in flush_to_ldisc
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>
-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 5a3fa8913880..23de97de09a4 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -467,7 +467,7 @@ static void flush_to_ldisc(struct work_struct *work) | |||
467 | struct tty_struct *tty; | 467 | struct tty_struct *tty; |
468 | struct tty_ldisc *disc; | 468 | struct tty_ldisc *disc; |
469 | 469 | ||
470 | tty = port->itty; | 470 | tty = READ_ONCE(port->itty); |
471 | if (tty == NULL) | 471 | if (tty == NULL) |
472 | return; | 472 | return; |
473 | 473 | ||