Skip to content

Commit 991a251

Browse files
H. Peter Anvingregkh
authored andcommitted
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>
1 parent 943210b commit 991a251

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/tty/tty_baudrate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
7777
else
7878
cbaud += 15;
7979
}
80-
return baud_table[cbaud];
80+
return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
8181
}
8282
EXPORT_SYMBOL(tty_termios_baud_rate);
8383

@@ -113,7 +113,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
113113
else
114114
cbaud += 15;
115115
}
116-
return baud_table[cbaud];
116+
return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
117117
#else /* IBSHIFT */
118118
return tty_termios_baud_rate(termios);
119119
#endif /* IBSHIFT */

0 commit comments

Comments
 (0)