Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1934855imm; Thu, 24 May 2018 03:11:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwjyE2xzx1iZINSZ31/BAmQcyY5dj+unKwl9/+bVitVypwhB59NI5MKtk3+/xIAApED297 X-Received: by 2002:aa7:82c7:: with SMTP id f7-v6mr6579589pfn.218.1527156701586; Thu, 24 May 2018 03:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156701; cv=none; d=google.com; s=arc-20160816; b=hqFOVQQEUrOCJomsULYnol4umhG7AIBijaGKJXn91KLvtsyYSGWYQIi16eJb4Ru7lG H2KxOcAJj2HnQTAH3gTQbzxunvLzyocpYYkVR9WNd+7J+FE5IO9ZNv3rZPK8o8GHW5iR CItCaZf20wRJr2F83Ha+MsjKHc3uY+kiDBEtgy/TwJlimcb8jvvLBrz5a/mspHCMbLGK hVXevbHAFqc7OlcqsNHdKj5EhB93BblriNSa0cNFYHjySyDlphpgPtFDzzkEhhfCWMq/ 3WeTs/hdE501GjdXfZtOz1Rhjq+3DYU7dLgyO7dZYZnUo/xvWvJEbK8ka41HOzw3vLQr AX6w== 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=HxzUoSN2Jz3tY5Dv4761BNUGzEublPYjsdIlxSrgjaw=; b=vECLm9ODgnB7X+mJEWqx4v92dDkfRpVotREd5B5yrk5XpU68YM6vj4XBKCEUYOSlfk gDTspT3ic+CPMS5Q0X1bBYEm4PxzYT3nIsqbqEOcBXNfsGoRleq51hgog7JI6e/VwTkB vswjukmyDOhIkCzo+etHM1p/CGtTOh0SBJe3Qha6ufwP9BfAuhEwGn5SDqLyIC4h47eL g4GKMz9klGfwVf2oM1c4u527Hug+XHJvsQVaYlgsF0gF9PKVkTcaYxntGH2e9JmV1LCG VwTjMV1UswGfxN9SPoPEzg9E/Rw0jDKvW8fnzC/XiQ5ojzWysS77a3OqqwIbd+94WlV7 vF4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E976rN38; 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 x17-v6si21304979pfh.354.2018.05.24.03.11.26; Thu, 24 May 2018 03:11:41 -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=E976rN38; 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 S1031600AbeEXKFc (ORCPT + 99 others); Thu, 24 May 2018 06:05:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031585AbeEXKFY (ORCPT ); Thu, 24 May 2018 06:05:24 -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 B03F320896; Thu, 24 May 2018 10:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156324; bh=YlMts+5hEmsFP01xvgcpevLjWfvlB2M4zLGu+kIdG+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E976rN38TqObh8kVh6eyb1y/hLM3UrT1SpOcR/UNxkORrt9KA0ovCjIL7BtK0Y2No P9XWut6l5tdBjzxKSwpMp4um1jiMkp2PijSiOxyDY1fd1Ccm14uCatPQorZVg77IJo KW86iXLq8MA64hsvuUo75GoCwZU2u8q63F8fH3kk= 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.16 146/161] serial: xuartps: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:31 +0200 Message-Id: <20180524093035.835781973@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 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 @@ -1110,7 +1110,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)