]> git.baikalelectronics.ru Git - kernel.git/commit
tty: fix data race in flush_to_ldisc
authorDmitry Vyukov <dvyukov@google.com>
Thu, 17 Sep 2015 15:17:08 +0000 (17:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Oct 2015 18:03:40 +0000 (19:03 +0100)
commitb8423cc289de2eb49cc6a05d11b2b94cbc5a0466
treed5faab1ed808c7fc3d55be88d431452b43e1e63e
parent1821d3d3835e21398afe8ef82423ce8f031e8aa0
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>
drivers/tty/tty_buffer.c