public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH stable v2 1/2] termios, tty/tty_baudrate.c: fix buffer overrun
@ 2018-10-22 16:19 H. Peter Anvin (Intel)
  2018-10-22 16:19 ` [PATCH stable v2 2/2] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 H. Peter Anvin (Intel)
  2018-10-23 14:53 ` [PATCH stable v2 1/2] termios, tty/tty_baudrate.c: fix buffer overrun Greg Kroah-Hartman
  0 siblings, 2 replies; 5+ messages in thread
From: H. Peter Anvin (Intel) @ 2018-10-22 16:19 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: H. Peter Anvin, Greg Kroah-Hartman, Jiri Slaby, Al Viro,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Thomas Gleixner,
	Kate Stewart, Philippe Ombredanne, Eugene Syromiatnikov,
	linux-alpha, Alan Cox, stable

From: "H. Peter Anvin" <hpa@zytor.com>

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: H. Peter Anvin (Intel) <hpa@zytor.com>
Requested-by: Cc: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Eugene Syromiatnikov <esyr@redhat.com>
Cc: <linux-alpha@vger.kernel.org>
Cc: <linux-serial@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: <stable@vger.kernel.org>
---
 drivers/tty/tty_baudrate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index 7576ceace571..f438eaa68246 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -77,7 +77,7 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
 		else
 			cbaud += 15;
 	}
-	return baud_table[cbaud];
+	return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
 }
 EXPORT_SYMBOL(tty_termios_baud_rate);
 
@@ -113,7 +113,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
 		else
 			cbaud += 15;
 	}
-	return baud_table[cbaud];
+	return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
 #else	/* IBSHIFT */
 	return tty_termios_baud_rate(termios);
 #endif	/* IBSHIFT */
-- 
2.14.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-23 20:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-22 16:19 [PATCH stable v2 1/2] termios, tty/tty_baudrate.c: fix buffer overrun H. Peter Anvin (Intel)
2018-10-22 16:19 ` [PATCH stable v2 2/2] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 H. Peter Anvin (Intel)
2018-10-23 14:53 ` [PATCH stable v2 1/2] termios, tty/tty_baudrate.c: fix buffer overrun Greg Kroah-Hartman
2018-10-23 16:02   ` hpa
2018-10-23 20:14     ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox