Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1933477imm; Thu, 24 May 2018 03:10:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnlhTk0eEjDu603URRnAd7pdRON17NJMteCJusoYZS0qR3oB/WQW27X2csnkuKJLiLHtuM X-Received: by 2002:aa7:8305:: with SMTP id t5-v6mr6610132pfm.198.1527156622165; Thu, 24 May 2018 03:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156622; cv=none; d=google.com; s=arc-20160816; b=FWn3tAFicyxgUjrJkmpJ3y+A02pE3Q7kAczhu/SdBn3uTBLgUJJ1IGWyN25EIjQ0+X E1CrwY1BTUCQplmkk3u+1KVDKgcuQuG1Zrj7n9fGOJBSa/bbOIIDXD3oqbDNseffhp3c BqQWrJg7DfTQx6hR/dMjiIK9mJ09JpMXq643A8HTdPpKwIeHaJhhnK0bRItp8olwY21U 5fJU5i990DZFlvAw8eGC02CaXYHCqDMSbEQvxlt5tTKw8s3I6QwPAXkOfF9BnR6DrIQO 870ua61elpwCwpeT/tHHOnL/6o2tKS/YB9KJX2JgjbbUnUIA9QBa3bZtvem0xBKwHEpt L5TA== 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=Leiu5Ll9C8+uhf7pR1VoQHXL5m/9mlGj6qBdhJEvps4=; b=BEpxfPuPFHvl6wl/56q/aVxYD7GYaAuAnIK0q/9vtmQrxkiIsebKQejfHUucv3l5Z0 00pay8rJAOZ0JDlhFBloSB8Vy09eBiDCuGL1z4twDZBOXwfyIqkUkmRTT51AWciFt4el eD2LtWdi2xOcGx2bWMY4ChR2k1nlf2uZQR97I30bbk4vf+kLz3cDXRhksdbe80OYjiLS C4P9ZFxuZAvjpNeuev+Dq2VZ8WWeYTNMHTgaFe54yFG6uEoZ5Ckezt7MuWupagCWma3y F3974tCnMy7vBI51idMGHLV2ifmKJctCJx8CnL3rEdYDihsjdxr1sAUqK38LHOiznuZj +yeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HCfRq5aF; 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 i64-v6si20974271pli.224.2018.05.24.03.10.06; Thu, 24 May 2018 03:10:22 -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=HCfRq5aF; 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 S1031653AbeEXKF6 (ORCPT + 99 others); Thu, 24 May 2018 06:05:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030890AbeEXKFi (ORCPT ); Thu, 24 May 2018 06:05:38 -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 2447D208A3; Thu, 24 May 2018 10:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156337; bh=Se09nY1qrGi2sTZo15rHkEDVWxMz8XKfbYX9e5eLAw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HCfRq5aFTpsGkUHk4OHoQeBMANfEhdr43y7TTaH9r9bdeyrYPyDm8KLc4isjbbgOv OVIm2O2X7KkHV4Zar1dGNKTtu2AiLUEBqEB1zXv8lKFzOinBlW4T89n6XBdxzzCyoI BQV8k2Ff7iJzdU6FnWiTF743TcDTV3YfxRgzEUN0= 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.16 151/161] serial: fsl_lpuart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:36 +0200 Message-Id: <20180524093036.371928666@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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.16-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 @@ -2145,6 +2145,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);