From patchwork Tue Feb 20 09:40:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10229703 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7306E602A7 for ; Tue, 20 Feb 2018 10:00:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 643A4285D5 for ; Tue, 20 Feb 2018 10:00:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58C96285D9; Tue, 20 Feb 2018 10:00:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09510285D5 for ; Tue, 20 Feb 2018 10:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbeBTJ7Q (ORCPT ); Tue, 20 Feb 2018 04:59:16 -0500 Received: from laurent.telenet-ops.be ([195.130.137.89]:60190 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbeBTJ5Z (ORCPT ); Tue, 20 Feb 2018 04:57:25 -0500 Received: from ayla.of.borg ([84.194.111.163]) by laurent.telenet-ops.be with bizsmtp id CxxM1x0013XaVaC01xxMeB; Tue, 20 Feb 2018 10:57:24 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1eo4fo-0002mu-Uq; Tue, 20 Feb 2018 10:57:20 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1eo4PU-0000Lz-FG; Tue, 20 Feb 2018 10:40:28 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: Barry Song , Vineet Gupta , Jiri Slaby , Michal Simek , linux-serial@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 8/9] serial: sirf: Fix out-of-bounds access through DT alias Date: Tue, 20 Feb 2018 10:40:23 +0100 Message-Id: <1519119624-1268-9-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519119624-1268-1-git-send-email-geert+renesas@glider.be> References: <1519119624-1268-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sirf_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. Fixes: 66c7ab1120585d18 ("serial: sirf: Fix out-of-bounds access through DT alias") Signed-off-by: Geert Uytterhoeven --- drivers/tty/serial/sirfsoc_uart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index 9925b00a97772a1b..701df3319ff7579d 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c @@ -1283,6 +1283,11 @@ static int sirfsoc_uart_probe(struct platform_device *pdev) goto err; } sirfport->port.line = of_alias_get_id(np, "serial"); + if (sirfport->port.line >= SIRFSOC_UART_NR) { + dev_err(&pdev->dev, "serial%d out of range\n", + sirfport->port.line); + return -EINVAL; + } sirf_ports[sirfport->port.line] = sirfport; sirfport->port.iotype = UPIO_MEM; sirfport->port.flags = UPF_BOOT_AUTOCONF;