[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1539530740.792110024@decadent.org.uk>
Date: Sun, 14 Oct 2018 16:25:40 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org,
"Geert Uytterhoeven" <geert+renesas@...der.be>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>
Subject: [PATCH 3.16 018/366] serial: arc_uart: Fix out-of-bounds access
through DT alias
3.16.60-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <geert+renesas@...der.be>
commit f9f5786987e81d166c60833edcb7d1836aa16944 upstream.
The arc_uart_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.
Fix this by adding a range check.
Note that the array size is defined by a Kconfig symbol
(CONFIG_SERIAL_ARC_NR_PORTS), so this can even be triggered using a
legitimate DTB.
Fixes: ea28fd56fcde69af ("serial/arc-uart: switch to devicetree based probing")
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
[bwh: Backported to 3.16: Put the check in arc_uart_init_one() and move
initialisation of the uart variable below it]
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -531,8 +531,14 @@ arc_uart_init_one(struct platform_device
{
struct resource *res, *res2;
unsigned long *plat_data;
- struct arc_uart_port *uart = &arc_uart_ports[dev_id];
+ struct arc_uart_port *uart;
+ if (dev_id >= ARRAY_SIZE(arc_uart_ports)) {
+ dev_err(&pdev->dev, "serial%d out of range\n", dev_id);
+ return -EINVAL;
+ }
+
+ uart = &arc_uart_ports[dev_id];
plat_data = dev_get_platdata(&pdev->dev);
if (!plat_data)
return -ENODEV;
Powered by blists - more mailing lists