Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1931045imm; Thu, 24 May 2018 03:07:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZop+cCi6H18lEF/l2hh+b5c0jgmg/EUkv6gkyDojWgK/Fzio3OWed0dd9qxRrMN/1E6IQP2 X-Received: by 2002:a17:902:a5:: with SMTP id a34-v6mr6694026pla.58.1527156475302; Thu, 24 May 2018 03:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156475; cv=none; d=google.com; s=arc-20160816; b=f+T1qAW7caBILb2A1BuFb55X3aIvBrl8utkCQXxCuO+lNUZl2F3BF77Rs+Lo+0XBOQ mBfiqZIhXWmU1/mw8y2I+vO6OnYc+39Nhx+Xrx1eh+BUSA7kJ3uhG9TmRwVjBLKcrF6u Dcc0+fHhB5qYKe9XvodSnW1OTeGoy2Tl8ehMtO/ZITsv8uiMPdYw4nUSeyz+CpyCnGKU 8nXvIDAD/HPxpLhs9l5AT42wxtnkCKoETaCGqpholmtrRVTIC4+R3fMY9dnAIoSnsTcW TtlxBNKBqnY0wx0KfSpYgwDBCsuMfF67K3d7jXNGgcruPIPssvmFmnygBencnaA6+Mn5 Juqg== 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=9bFhn2TlvvHl/aJCfh++FU1z3162GBByFxzZZscQMSg=; b=H/ufhk6u53RfdyuXIdHezQ+BO6EbKHRwhSODPZJJdPpFaXlOKqJj74qyYOEbPVzXA6 lNn/8f7Gs5Os6+eD+ag9nXHXzVG2CH6kpgV/EtUcmPtrBIu4+ydITcKsG3XZhdmLZjHc QXpZ8fDGkSmO9D9SfYpTMqr8Kk6PxADs4L5lIA10PGGKieIfam0ty/095TBEVnxSzl4v yrfD1vipItd5knF1W3xJ6AAULzodK4pZQ6P+BEyUOH6oT7devOd00fil0S10W9stwXNy zPQqkSto91/MD5aBosH5lbsi1XDZToXL6yX6yxnx6KvT1ltTD9urVdziv+p9Ls6N50vX AiLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XRRu0cqJ; 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 3-v6si21255441plp.515.2018.05.24.03.07.40; Thu, 24 May 2018 03:07:55 -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=XRRu0cqJ; 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 S1031639AbeEXKFz (ORCPT + 99 others); Thu, 24 May 2018 06:05:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:54780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031130AbeEXKFk (ORCPT ); Thu, 24 May 2018 06:05:40 -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 C0AF9208A5; Thu, 24 May 2018 10:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156340; bh=3E2GNedmAjEFB43xhPhDMxkV86BP6PJHNTJBGQqzWKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRRu0cqJmnQs4M4IAim3jadZmIJ6sRbS7cml0EojIAh0L32+6Zq/6aQcFuhN1ql0i wWCMSjfNjQrglTOOBlKFeVFeKSEUuudVL6ihsUp0pTRuBNOm1vpNCZaVsFyV2pF/v+ zROZXmfXEkOi1xawA2odaHvzwbczNXOdY3L6Fydo= 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.16 152/161] serial: arc_uart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:37 +0200 Message-Id: <20180524093036.463094416@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 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 @@ -593,6 +593,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;