Commit 546e99d8 authored by Peter Hurley's avatar Peter Hurley Committed by Luis Henriques

serial: omap: Prevent DoS using unprivileged ioctl(TIOCSRS485)

commit 308bbc9a upstream.

The omap-serial driver emulates RS485 delays using software timers,
but neglects to clamp the input values from the unprivileged
ioctl(TIOCSRS485). Because the software implementation busy-waits,
malicious userspace could stall the cpu for ~49 days.

Clamp the input values to < 100ms.

Fixes: 4a0ac0f5 ("OMAP: add RS485 support")
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 11324115
...@@ -1350,7 +1350,7 @@ static inline void serial_omap_add_console_port(struct uart_omap_port *up) ...@@ -1350,7 +1350,7 @@ static inline void serial_omap_add_console_port(struct uart_omap_port *up)
/* Enable or disable the rs485 support */ /* Enable or disable the rs485 support */
static void static void
serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
{ {
struct uart_omap_port *up = to_uart_omap_port(port); struct uart_omap_port *up = to_uart_omap_port(port);
unsigned long flags; unsigned long flags;
...@@ -1365,8 +1365,12 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) ...@@ -1365,8 +1365,12 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
up->ier = 0; up->ier = 0;
serial_out(up, UART_IER, 0); serial_out(up, UART_IER, 0);
/* Clamp the delays to [0, 100ms] */
rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
/* store new config */ /* store new config */
up->rs485 = *rs485conf; up->rs485 = *rs485;
/* /*
* Just as a precaution, only allow rs485 * Just as a precaution, only allow rs485
......
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