Commit 2766ffe4 authored by H. Peter Anvin's avatar H. Peter Anvin Committed by Kleber Sacilotto de Souza

termios, tty/tty_baudrate.c: fix buffer overrun

BugLink: https://bugs.launchpad.net/bugs/1810947

commit 991a2519 upstream.

On architectures with CBAUDEX == 0 (Alpha and PowerPC), the code in tty_baudrate.c does
not do any limit checking on the tty_baudrate[] array, and in fact a
buffer overrun is possible on both architectures. Add a limit check to
prevent that situation.

This will be followed by a much bigger cleanup/simplification patch.
Signed-off-by: default avatarH. Peter Anvin (Intel) <hpa@zytor.com>
Requested-by: default avatarCc: Johan Hovold <johan@kernel.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Eugene Syromiatnikov <esyr@redhat.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent f5df61b5
...@@ -330,7 +330,7 @@ speed_t tty_termios_baud_rate(struct ktermios *termios) ...@@ -330,7 +330,7 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
else else
cbaud += 15; cbaud += 15;
} }
return baud_table[cbaud]; return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
} }
EXPORT_SYMBOL(tty_termios_baud_rate); EXPORT_SYMBOL(tty_termios_baud_rate);
...@@ -366,7 +366,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios) ...@@ -366,7 +366,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
else else
cbaud += 15; cbaud += 15;
} }
return baud_table[cbaud]; return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
#else #else
return tty_termios_baud_rate(termios); return tty_termios_baud_rate(termios);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment