Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2013832imm; Thu, 24 May 2018 04:31:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqD3Qs8Lm3uWEnAEjPPJToEKUIxEhqQbyZXUV4+rllJPT8Jrh6qGQcOoEJMFjEoxRLWdMOs X-Received: by 2002:a65:4d08:: with SMTP id i8-v6mr5533621pgt.51.1527161501460; Thu, 24 May 2018 04:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161501; cv=none; d=google.com; s=arc-20160816; b=obSs4CRiM9FnhObM/0yO3CpSgQ/PoGuaeqOx2a0Dx7btvdITy3YMh9INHthgPq8ld8 9c8fNy9qsiCoxz6jgghopDOglx+MfPTlF/mqadWmWbxpL94g7hWLpyTWPsQSjSSaNF6Q DluyGgfPI4rZkoArXFg+j0/o8mcrgtXCAbHMq5NkR84JRGN7CBEcurOuaQY4/r1vJlgQ INNC6HXLf6gDGUKK4RBuEpq/vNmsENry1T6lYmCusbjQlUAwzaPaTGuuYUIIOHC/pcdw V7kz7TvbXAQZzDiNMPg3xu9vLQtIrJboQHj/8isgFpGt9JMfGsDG5Be7Q9W21dBfw/Mn +3Bg== 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=K3JeTACyoB7pqpxxwJywL3FMuXnB8bx1N4hY129McnU=; b=SO010pvaJpLfsSdRtDdpLKDmwVNZMfkMoCeJo2//HNC2wRcjS+pfm50V1VHLCNqkoi +WjRK+o8MWX/42LLJ8JnDmotvXU46y+j970vLhkSWiYUd7QPuE9PJvZ/k8BVJpZRbqeu 1XSRjfoYRocGI8JJH24RGutkaqcWpn/3uOvloxPCI3Pibv/eBOCcWf/6mYRay1Ek6m/G al0s6cMo66+QO0DXreBaz6xjBXmSVLNtYM2HQRyb0nqs0rkBxgPnfDC6iLw1C4UvQN58 fVFmw0k3yNlm3hiqk/OZj2Bm7ABt6fhTSykzbKJwq3eqxPSjs/KkDVup/hwU58UXTXAJ yNAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FsATF58U; 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 n2-v6si21927612plk.433.2018.05.24.04.31.27; Thu, 24 May 2018 04:31: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=FsATF58U; 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 S967490AbeEXJvH (ORCPT + 99 others); Thu, 24 May 2018 05:51:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:44182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967220AbeEXJvA (ORCPT ); Thu, 24 May 2018 05:51:00 -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 53251208DF; Thu, 24 May 2018 09:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155459; bh=Xp+uzXNKwfZIOe3K30UaZZyxvkpeX4ZBpMJBCevykc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsATF58Ub3EyU4LQmubZKrH2rB6FaRE0u4vmENQU2RI9WEydjwQrrbaPES1unxzYZ BWcsPQ7JzrGGO4TkF7IMcJ27r68dtPpMEYrlYyTJJY/F/qHvYuZBJBw0+iW/EGnxTk pQchFfBftyRNhRXp24Bgx0iNxyfKoS1QXTnfKNIg= 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.9 92/96] serial: arc_uart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:15 +0200 Message-Id: <20180524093611.111714981@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 f9f5786987e81d166c60833edcb7d1836aa16944 ] The arc_uart_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. Note that the array size is defined by a Kconfig symbol (CONFIG_SERIAL_ARC_NR_PORTS), so this can even be triggered using a legitimate DTB. Fixes: ea28fd56fcde69af ("serial/arc-uart: switch to devicetree based probing") Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/arc_uart.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -596,6 +596,11 @@ static int arc_serial_probe(struct platf if (dev_id < 0) dev_id = 0; + if (dev_id >= ARRAY_SIZE(arc_uart_ports)) { + dev_err(&pdev->dev, "serial%d out of range\n", dev_id); + return -EINVAL; + } + uart = &arc_uart_ports[dev_id]; port = &uart->port;