Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2015481imm; Thu, 24 May 2018 04:33:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo94XcqWJqEnJr8CHcs7B9VzG6qA0kza1S4Cv2luXqk0E6RPOYF4i/JN7vKJGXYqEP44iyM X-Received: by 2002:a63:5d6:: with SMTP id 205-v6mr5335559pgf.272.1527161600462; Thu, 24 May 2018 04:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161600; cv=none; d=google.com; s=arc-20160816; b=UKtHVg4Q0eyM78K4Ge3KjwTqzvEP7lr+nJ4iWoX8vSvFMI2CZ1MP0/GmcfGGn6fSnc N7szI3aZ0RIwivSpSoxcsiBvuZ9avX7mF5OMC+577zmHUmS7P3NyoVpSlQ19S5FUzyE7 RGusNQgBjjyqWm7+zRpoHE7+NuQ/BR39BxOXKUgh6DItYCbWST5/E8vaYNJsNcGsvvXA 2iO+lqDqFGY7lHaujH79iMvbYzOh6gr//CmMt1DAUx++YgLzo/t+baSPKim5ypGMr7z9 gt9Fay25jlGa9V4k+pkK34GUgwEd+C8v5+yUJLKHBP6P3VzcvFkVWlvWwhjc7Ijdc/DP jZPA== 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=JyEHtIABPWjf5f9vtolMW4GbunwG2PM1gi2LPv2kAdQ=; b=R3DB0JNxq3SpgCb1WRWMAKp0YU9pGFoyc9mppliDil8Loq9lx5WDZBcYnJmcHhWS9l HknZ+ETvL9Mi/qgMvhK9qm7KzLsOa95rTU44UlV0pl6e9kEklcOM1Ak3wJt9LFBjOF1X EccpfOUGdAs7S47I2XTpIl7mYpgxskmsAOFn9mr0CusPEW60FbaKvoK97s5aLHHaOKYJ jdG7fA9Hghc9YpGOCtwcOwB7LRv21IiBOGC1iMHkZKYIGufa94o1Eh3LTqNhXuGN2181 koawb8TO2L7iAWh4sgVNKGtuP5REmn/c41IpKTmtpnCW+V1tLaW0WCHtArP8Sg/WQzuX A/NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zt6/xEbt; 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 c14-v6si20669843pfe.29.2018.05.24.04.33.05; Thu, 24 May 2018 04:33:20 -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=Zt6/xEbt; 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 S968893AbeEXLb3 (ORCPT + 99 others); Thu, 24 May 2018 07:31:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:43934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967129AbeEXJu5 (ORCPT ); Thu, 24 May 2018 05:50:57 -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 A69BE208AE; Thu, 24 May 2018 09:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155457; bh=wgHG5+9HDna2jxI2x/tlgeI0n4cZrsE5BGQdG9iPano=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zt6/xEbtVqraBLTuIT0FPy/6MpwSVRV+2G0/2UCWJaTc9aO3WGoXmspR68iQy58or lHrdeN8zj7HZWAJRH61utZfQlP1f+FR4ReK35Ul9KKpfwyjk28t1TVpaMPdu9ddtQX elarpXdNzZ/adZ8VXdzUqIm/9ShRICW+5L35Vl8I= 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.9 91/96] serial: fsl_lpuart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:14 +0200 Message-Id: <20180524093610.997169040@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -1902,6 +1902,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; sport->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart");