Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1963006imm; Thu, 24 May 2018 03:40:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqqe9ea6r0gHB0z7W2iK6SfCGEQPWrqcX///d6W5U/U/KimxWCJ7HkUpmXrBFJSos3/xk0R X-Received: by 2002:a65:4188:: with SMTP id a8-v6mr5412841pgq.118.1527158432969; Thu, 24 May 2018 03:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158432; cv=none; d=google.com; s=arc-20160816; b=JxPyE4E+mBHgFqo8OddeXQi3ecRO4GoTb0Dpv0NDzjvAcqJJ489P8lOQ2uwYtAKE+z a31HJ3Pbv7JzSoRyydDfKHawforxrRTwtSVq7QFlwf3nRhV1gTW1hy7dLeevKtDRGBii t18mlUv+wOQC8CUtboAu22WmrylWzoLrFsr8dW/RNT/BGPgsJ89RqE5aKfqEnRUa7f2e AFYTqQH8hGodnb6i/HMDt0x2+DfC4d+s8vLFvHSpTFJw5HvWa2g0Xu2EtbM5NCajsNz5 drGhKmheZUdAggDHQTfT1ydkJj+67X9XLVke0b5huB0J65neAFE/kcYHZmFpQgGymwO0 3h3A== 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=2/CO5jRaGlqHPbwDelDBvIyy8Vz3FI0lrNfIprdVdms=; b=nxrlKt2QKoEvlYJxZ/+qZBF2odIgjsuvqcC6OzFN16/mwXd9ta0GWRrKeexXtoA+JC j5DCb0NTsmdUuuq0UZ2YF9V2a3tqtOAaprWLjPErmOwqmyNTOozmHKZIPg1CwEaZudDS LOJQbt6tXkaNBH8b7QLJwI4Vdc5aH9Gy1ggwaTnsdCX5p45plHXhhUVWM8of6CpRIP5D CfaEzNh8kucVn/AXtGCqeuyIaS8gUmYe4tgg86TVrtgQj88GbE4SngEvMtx9zuqppkki XbT+JazcJVFs04s0fZDCN5j0NNvC+lmmwAkGBdhADvMqN5Z4sYZe6djlkquGs34QS2T/ HJDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1i7JZNki; 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 d9-v6si21344535pls.334.2018.05.24.03.40.18; Thu, 24 May 2018 03:40:32 -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=1i7JZNki; 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 S1030734AbeEXJ7P (ORCPT + 99 others); Thu, 24 May 2018 05:59:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030419AbeEXJ7D (ORCPT ); Thu, 24 May 2018 05:59:03 -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 D1D112088E; Thu, 24 May 2018 09:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155943; bh=p+2W2AFTNsGX0HeWwgdvajHM2/yAHvMXAk9eeU4ubCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1i7JZNkilCuZYH/xzT0uybmVyj4AnxHvkAuc9IvR22TxcoU5vBdBdLN/kapdA1poA sWXQdSBSkJpJGefhrJ5U+rkOLFZ8EeWfTs33WtZFb0JMLEn5WROQctxjaNKaMhY33n k6N9z9LVQadLNGH0DpGLNGuhS2nHzto127PdGCGc= 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.14 150/165] serial: xuartps: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:16 +0200 Message-Id: <20180524093628.149787831@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 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 @@ -1115,7 +1115,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)