aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-10-22 12:19:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-08 06:36:45 -0500
commit991a25194097006ec1e0d2e0814ff920e59e3465 (patch)
tree9e5c39ad649fe32166e66eac2fd6bbf79bd6257e
parent943210ba807ec50aafa2fa7b13bd6d36a478969b (diff)
termios, tty/tty_baudrate.c: fix buffer overrun
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: 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/tty_baudrate.c4
1 files 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)
77 else 77 else
78 cbaud += 15; 78 cbaud += 15;
79 } 79 }
80 return baud_table[cbaud]; 80 return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
81} 81}
82EXPORT_SYMBOL(tty_termios_baud_rate); 82EXPORT_SYMBOL(tty_termios_baud_rate);
83 83
@@ -113,7 +113,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
113 else 113 else
114 cbaud += 15; 114 cbaud += 15;
115 } 115 }
116 return baud_table[cbaud]; 116 return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
117#else /* IBSHIFT */ 117#else /* IBSHIFT */
118 return tty_termios_baud_rate(termios); 118 return tty_termios_baud_rate(termios);
119#endif /* IBSHIFT */ 119#endif /* IBSHIFT */