From patchwork Tue Feb 20 09:40:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 875453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NzShpOed"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zlx1P0657z9ryy for ; Tue, 20 Feb 2018 20:59:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yX7HlLieM5VEWsH+jdd0/SvO+Ip4VY3vrYmGD+RU35g=; b=NzShpOedlPWfd9CXW5wH7RWQp5 qeRxqFlxPWgZmd2L4lSiZrATXs9Mx1IPNC+e1uIUYWHkMt7J4oJ7dSbE5pqrM+m1A0Ie1Fqn55DOl cDiy/jUdYHXmhzvp2UH+/ugcURWKJUVcjCIDR2CiOfTVQN23IMwOT7IVodlY0AhKewxY7+JHn0hT+ pA/jhEG0Obj3DM772VBSZ//aEcRTwzdjPRYb+77y0rQsa8EW18q5zmIsJI9I/7yMQsRU8u0XsDhwQ IlTGv/XoUaFylBz70KdpYtvHsYnGTEasLo5pI8wOaMc7r8Kna0ciTeSw6QAsO124FxeDLZGc55yiD lFh6ncrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eo4iC-0007YI-PI; Tue, 20 Feb 2018 09:59:48 +0000 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eo4g6-0006QU-GG for linux-snps-arc@lists.infradead.org; Tue, 20 Feb 2018 09:57:45 +0000 Received: from ayla.of.borg ([84.194.111.163]) by albert.telenet-ops.be with bizsmtp id CxxL1x00m3XaVaC06xxLa5; Tue, 20 Feb 2018 10:57:25 +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-P8; Tue, 20 Feb 2018 10:57:20 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1eo4PU-0000LW-96; Tue, 20 Feb 2018 10:40:28 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman Subject: [PATCH 3/9] serial: imx: Fix out-of-bounds access through DT alias Date: Tue, 20 Feb 2018 10:40:18 +0100 Message-Id: <1519119624-1268-4-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180220_015738_828608_2C7E6D80 X-CRM114-Status: UNSURE ( 7.47 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a02:1800:110:4:0:0:f00:1a listed in] [list.dnswl.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Barry Song , Geert Uytterhoeven , Vineet Gupta , Michal Simek , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The imx_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: 9206ab8a0350c3da ("serial: imx: Fix out-of-bounds access through DT alias") Signed-off-by: Geert Uytterhoeven --- drivers/tty/serial/imx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 1d7ca382bc12b238..e89e90ad87d8245c 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2041,6 +2041,11 @@ static int serial_imx_probe(struct platform_device *pdev) serial_imx_probe_pdata(sport, pdev); else if (ret < 0) return ret; + if (sport->port.line >= UART_NR) { + dev_err(&pdev->dev, "serial%d out of range\n", + sport->port.line); + return -EINVAL; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res);