Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7098296a authored by Dmitry Vyukov's avatar Dmitry Vyukov Committed by Greg Kroah-Hartman
Browse files

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: default avatarDmitry Vyukov <dvyukov@google.com>
Reviewed-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e81107d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -467,7 +467,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;