Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1936420imm; Thu, 24 May 2018 03:13:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpiJug87lx4I4En4ROMTcyj/PF11hWku+ytIBrXmXfmPhpCok2sFclhN6YnhjWHxwuAMhGN X-Received: by 2002:a62:d605:: with SMTP id r5-v6mr6681212pfg.8.1527156799675; Thu, 24 May 2018 03:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156799; cv=none; d=google.com; s=arc-20160816; b=DtKR8y676dO/PuVDah58uUCM7+MPjjKeA8DZInILueD+HFUscy1OyGjyLyUIazxNUq +oExcKHZKjGeN/lQJPOsFckjLf2VJE99LIvD/zdDMa9/rGfej7EG8QKJ114uOynxtpgJ qR9ID8XY66Lpx7meO0j13pLhoRqcBLASjfX7S5G6g6hu8Uu9K1dRMGwOTqlWfv8QU5fJ P/FNuqxQiu58BjR5L7cQmG5Qv8rV6mNUKTcdKssAz6q1Z6XAnncqzrqarNm6fULNfgsn qgt3tcEKxIBWeYYxJMrhlhOi//QeG5Kaj/xuSFiYvHf/VV8KXplDBpGHSuguMhkvmoWR sPFQ== 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=ruLEZ2CANCsjLvFGK+ke6yB4GVV04iT0gcSZrb7FctI=; b=cFj0GaFIVXI3Tkm/p6Bu1KBKzYdPqleHPKW4nkuf9lchfFzSJknwiZj/AOM/Gnx19D Xgf16GlzEc2zChW03holFuGLxuO0M1ZEqVKvo1t0QRcmhINRwHgXxWw5bUleMnmak+vD lYRk6vwKadF1H7IpYT8eI/V3ffu3C0B5aB38fD2HFr9r1v9i0jyEY2dB2BkQxvUrrmoY 29XpE10Ge+PgzJycApYODTTYFu/kK/qi+CDCC/aVFhxYShP3bCE9Z5vstobOx2UgfiJy IbJYEPLYlrIQtMuqT5qOdM759FJrnVcmtDOJYQjQba7aUszb1+b/Hpav+bTqjik5lN2H E0xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BapAV3Im; 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 p8-v6si20545880plk.441.2018.05.24.03.13.05; Thu, 24 May 2018 03:13:19 -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=BapAV3Im; 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 S1031680AbeEXKLF (ORCPT + 99 others); Thu, 24 May 2018 06:11:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:54612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031128AbeEXKF1 (ORCPT ); Thu, 24 May 2018 06:05:27 -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 5F60420893; Thu, 24 May 2018 10:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156326; bh=G/t+SsZxu+AZOoRjvSphETxEKtTROf2kB8X76rH/L+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BapAV3ImjWplTnpbnHBvrLxKk1SRVtO8fq0TM18LFGbhO/eh81j/VNDWzDCrk3hPw Sjjq7rs7D7oc31ERbhGrLsCtlvukN8S6Q2kn+KrvGd6ozTf0QkUZ8A5/dM2MqFUFnH oTOX/KmLeZbUeJmpDoKyqP+1+/hQCNlEbZLF7PRA= 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 147/161] serial: sh-sci: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:32 +0200 Message-Id: <20180524093035.922789778@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 090fa4b0dccfa3d04e1c5ab0fe4eba16e6713895 ] The sci_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_SH_SCI_NR_UARTS), so this can even be triggered using a legitimate DTB. Fixes: 97ed9790c514066b ("serial: sh-sci: Remove unused platform data capabilities field") Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3098,6 +3098,10 @@ static struct plat_sci_port *sci_parse_d dev_err(&pdev->dev, "failed to get alias id (%d)\n", id); return NULL; } + if (id >= ARRAY_SIZE(sci_ports)) { + dev_err(&pdev->dev, "serial%d out of range\n", id); + return NULL; + } sp = &sci_ports[id]; *dev_id = id;