Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1964680imm; Thu, 24 May 2018 03:42:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqlo4DQYtUamIIMmd05coLMQzeK7p7ym6apb+oS5RmQx0i0qkE6tsVTViQ2H40J6wvSbbmS X-Received: by 2002:a62:a48:: with SMTP id s69-v6mr6692893pfi.134.1527158532175; Thu, 24 May 2018 03:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158532; cv=none; d=google.com; s=arc-20160816; b=dM1eJNvS/kMFFH3ybhAyHBbcOltowIxNFjfc4IrsG7rEG7lZaLzY8x2kaMqytNOfS3 ZmyCCBD49QEWUbBG8McoBzy5I7qdfMBLffL+0SrcR2jlxODBAw+Fnv4vysdwzoIKmJNy Z1l+wvbRvFCovOtkrRcVUL4ETl6I8hQogWYambV3iG4YEs3gjxx2aTkUerPmtd8wAPpo oDpuf+BlAS9+bWNsNaPw5unFdJqoF2i0GBXUPlMztzMrIUJdRHIkAqs5V8E788+7R1c/ Rw3kVqviIy5rUsaL1qYbsGEgbQoHl4JF8cPQQd2J+JiimxKogGLtbtwj7FBLuaLu0NSl E+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=GVB8giei0PsBKSl4yvWce9JFElTOCixlJ0LN1B2Tte8=; b=u0CtsZs2WK8AY0xxgNSjGjqsZQLYL6uLhsd7f2S5GZEQl1suPaSw+rWUUICpRkJRNF BOMOQSiIXGRTowPVBT5pq8zoM7JlG2I4U+4If5iEmOFQHPMD8dBlcoeL9i1yS+L9TjWy a/anpdC5eG3pFbYPdMjUXnDornyAvzHbT3Qj3366d/KBFtFsjKwidnL8YYc7wzAXRItW vPhwHvgQUKL6uF2YNrzulANU36yr+Q+PI1MUHoJ66RreZUV+6egp7P2jPHgediYBiHbu eBm7E/zhGw9ax+n94RI2n3YdrSjgo9SXPfOsR2NNgmry3EpDSj3R0BZ5Z6XuvqWO900P pf+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CscCsy2n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91-v6si20370343pld.132.2018.05.24.03.41.57; Thu, 24 May 2018 03:42:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CscCsy2n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032290AbeEXKlT (ORCPT + 99 others); Thu, 24 May 2018 06:41:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:39080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030684AbeEXJ6t (ORCPT ); Thu, 24 May 2018 05:58:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D82320891; Thu, 24 May 2018 09:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155928; bh=8DZeYrauLX5X/OzJltVkuU8M2LCJvT4NBwHQuxVr/Ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CscCsy2nb8IOtUExfQnINxa0DVASFrFB0iuIy7RkA8w3qX9+n5OucNE8vR8IS9GsE AwaKvmfxdB7ijt66nbEen2cjC1TpcDgkjueyDUMax8rUjCXzuk8rwVRPM9udh/Tipq is8FOWINM6pYsAsuTXkhcj7vUC90ed+y3bMi4TGY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Sasha Levin Subject: [PATCH 4.14 155/165] serial: fsl_lpuart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:21 +0200 Message-Id: <20180524093628.346140258@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geert Uytterhoeven [ Upstream commit ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47 ] The lpuart_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: c9e2e946fb0ba5d2 ("tty: serial: add Freescale lpuart driver support") Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/fsl_lpuart.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2151,6 +2151,10 @@ static int lpuart_probe(struct platform_ dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); return ret; } + if (ret >= ARRAY_SIZE(lpuart_ports)) { + dev_err(&pdev->dev, "serial%d out of range\n", ret); + return -EINVAL; + } sport->port.line = ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sport->port.membase = devm_ioremap_resource(&pdev->dev, res);