Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2015386imm; Thu, 24 May 2018 04:33:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZperEYNbNvy8MwGzJoXcsxK7PD8IcHl14Ys2lz+UHv4OG1daiMrkFMvePK14A3fp/SVywPV X-Received: by 2002:a17:902:7484:: with SMTP id h4-v6mr3234825pll.154.1527161595372; Thu, 24 May 2018 04:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161595; cv=none; d=google.com; s=arc-20160816; b=brPEua3z47LsykekAHDucRw6SsSg/d5c957eA06bhvan4S497PCtumZ8Gh22svOUYN dF0/vP79O8PXtcf3m7QSLIBw5rqLYQCBFWOpeX1ZqyWFFzSmAGzBKbVqE4WZD1J9h8is zEmGkmmLTT2LMkmMQTTZ7vXlC5jmJLvdh7VMsuIcrdmcrFRtfttBxmubUQN2EgWIzW+I IVKcz0dbSIRXRsQDbndXxuUsHpv60+VZg47pTQtu/OOwLnMqmz6PhUgUH3+HKmxSXuJL FtIGunoeJ33o61ENNW97rVVc0DpCIPJbWSV5r4A32F4PPayoCxASc66gXQK7eztDu7zK sKMQ== 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=zaDiC9t7H2akeu/GtVUHMsTFDJ0grdAQNDbu56IXEd8=; b=mICs36nFOaaRJ0PB/CzR5vNTw+JNHXxby4ziaHf8IZmAkwIMuKire3k7WMqHSgy/K0 7ASRra0hIbNrvhM4KX4VOnDFi4+rEXIwh04eJfWRC8ELNvI5tDVZyz0ljOAQv9xbvpwO tVLE2CF7VbBGtZrraTzZxMxXrRqVO4RCPeR+y4XCbHRCi/AmpHPCV5IB5ugiHRs/0i5D 2dJKOjKdyCNInM4DWi92YJmY2dLbrLyCAr5+sw5jxXVfPXIF2/ZoMeOMif/fiYupjjk1 0/R6BnxN2RKlPpER+ann+24/aNYE4jSfLcJJZPWPfbD7g1kPZhAxkw0K7pcgo+uoAgn+ wGSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FsDIz357; 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 a11-v6si1675542plt.39.2018.05.24.04.33.00; Thu, 24 May 2018 04:33:15 -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=FsDIz357; 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 S969001AbeEXLcZ (ORCPT + 99 others); Thu, 24 May 2018 07:32:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:42768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967612AbeEXJun (ORCPT ); Thu, 24 May 2018 05:50:43 -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 D1BE620894; Thu, 24 May 2018 09:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155443; bh=7C7r9dJTwPzTuCsh7q5v6KlBax6JK1fEGlyPjUL3XyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsDIz357iI0ri922XXzFml6AdHf6rDXfYoRi862NYlz7QtMNQ1/ntwA6yID/6xfH6 uX8XLUAHWBzfy2tIhg1kHgdmtc6EgoV93ofMtIb/bEHAiSJEKk/mi7irYeEjmQS0p5 BgSPtFz9JiK9kciEtbK8XT+wx4d3VRboutqLrrFQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Michal Simek , Sasha Levin Subject: [PATCH 4.9 87/96] serial: xuartps: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:10 +0200 Message-Id: <20180524093610.542857764@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 e7d75e18d0fc3f7193b65282b651f980c778d935 ] The cdns_uart_port[] 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: 928e9263492069ee ("tty: xuartps: Initialize ports according to aliases") Signed-off-by: Geert Uytterhoeven Reviewed-by: Michal Simek Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1106,7 +1106,7 @@ static struct uart_port *cdns_uart_get_p struct uart_port *port; /* Try the given port id if failed use default method */ - if (cdns_uart_port[id].mapbase != 0) { + if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) { /* Find the next unused port */ for (id = 0; id < CDNS_UART_NR_PORTS; id++) if (cdns_uart_port[id].mapbase == 0)