Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: Fix race in the flush for some ldiscs

If you issue an ioctl to flush a tty as the line discipline is changing or
otherwise unplugged you can get a crash. The bug is very old but the rest
of the BKL lock dropping and some very "good" luck on Ingo's part caught
an example.

Use the correct ldisc_ref form so that we wait for the ldisc change to
complete and then flush

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
c0253eec 5393f780

+1 -1
+1 -1
drivers/char/tty_ioctl.c
··· 1057 1057 if (retval) 1058 1058 return retval; 1059 1059 1060 - ld = tty_ldisc_ref(tty); 1060 + ld = tty_ldisc_ref_wait(tty); 1061 1061 switch (arg) { 1062 1062 case TCIFLUSH: 1063 1063 if (ld && ld->ops->flush_buffer)