Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2499807imm; Mon, 28 May 2018 09:14:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrWwjtnny4VBkDLvAhRZ+bB6tn4oDIieiIBjd1HnlIdNG309M9+HgkmoG3ECqJnNTLoL5lG X-Received: by 2002:a65:4d08:: with SMTP id i8-v6mr9133093pgt.427.1527524064346; Mon, 28 May 2018 09:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524064; cv=none; d=google.com; s=arc-20160816; b=cYONLTGKCg2/UpGw1/PZyAiJH2Tq3vWTCsM4MnLmIkcBVb7frXmG02Cm8lB5xD/TWH MnkusYHbwil8raB/vDOkTZ2f80xFgltGKlr3ZEm38xQWq0ksOR6HNUvGIuR95h31v1pM VG5mkJr8Msp9kYOhhltlrAkWkmmJkZq0cMia3dU/LQTl7P3DXejxXdtSlSPg6s5T2FVh tptU5TPpjqbAemOw56MFVmXCrRy3zEwowxLAWGuWUybqvPJQJYHBNPWAdEd0uglLeKXV r7phYjGHHdzYmIS6of4gNjeE5h+rMTs6PRVEjNkrkJV0gZSpZm6puePJqmDm/kyh+I0V kqUQ== 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=eDhB0eC32I4fQiaFBnpEVwixykORzIPsYHigDC//fIg=; b=HSMXsihgoKYdMw4aaf1ntZNag1YLJC3g+oap8fRBssThy8wz3jRr6OZHcGIhe1ituU tjLXYNimoJ6SSN6Zt6o6d4HqRXvNaxXW5VLKCiXIFS+tnTz3MfIix9GZQZuFROfl9ZPx NhaWec58fiUPjplThQbFRCBP9lY3UApq3GuXLMqAOqeOt7hneBjn6p8Aj06mMGYx3J8U n0wxs2BV7Cz8GzwR8G94WkaAhpkihexnwM4m9hA8LkpuiYamcVkp0CntKSrVkLJFCyx5 HvCtYr7KbT9xOBkxoYJD4s5JCdeuBhPg1up9Fux9P58aWCmDJYg5SHeQiU1bNJJFgJs+ mV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uSU+VQfE; 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 67-v6si30306791pla.475.2018.05.28.09.14.09; Mon, 28 May 2018 09:14:24 -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=uSU+VQfE; 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 S933455AbeE1QNi (ORCPT + 99 others); Mon, 28 May 2018 12:13:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965325AbeE1KNK (ORCPT ); Mon, 28 May 2018 06:13:10 -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 0A99B20843; Mon, 28 May 2018 10:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502389; bh=z0FTWxqgPeCu65uhqiakmDwUFpaC8edm+DIhPlRVYgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uSU+VQfEyPfGlsaSPalF8YQ0uFf+1v8tWBVkgjvRT/pNkG+EqzOs1Tz2CbyszBTw5 1K3csbLxDVngfXtxqLmESNf3Kjvx8sE5U+EFbsMZl5FQsYYNyHqKb9gXvo12nwqA2T Oa6rRC2FH8qEWEYFjKLs+s2cn+sNchGujXhEf/Lw= 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 3.18 167/185] serial: xuartps: Fix out-of-bounds access through DT alias Date: Mon, 28 May 2018 12:03:28 +0200 Message-Id: <20180528100112.974627197@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -1001,7 +1001,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)