Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1965784imm; Thu, 24 May 2018 03:43:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp7HCCYAQjuiC2DWQTpDbcebSoq/dBTychqeA5cmnC/h/Ys765Jyim9XUk/60lN9pl38zxL X-Received: by 2002:a17:902:758d:: with SMTP id j13-v6mr6894978pll.188.1527158598209; Thu, 24 May 2018 03:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158598; cv=none; d=google.com; s=arc-20160816; b=cKiiwcBBVrIoLBb1vviEZBkoI0jUlCncjvNfW3qkepy7nvOoT7NSRNNGHd9V2u9xTo /FiVBQbFtfFi9EzFls21lLVGZxf6lJC8mia2BJFrX3WZWmrOQFD7e7KwQibEGpWsED3H 83gFfxPAwbXU/UY0KOxo3UqhKEka+r4suYCsnihDzfJ+y/cGmw53o3ppnkvcZkecrElK 21OWSfq2Xmx1/JopTWvvu2ihab1toQxmh0yaPTM4MWdIeYGS99Ucf2QWM3tGOgt8MOhA ZYRgrE1kPzmARq5GCSEpg14qrLsOUZ3F7x56MgnYM3nUHCU74VIsK5rROkzVZLjRKh7n a59g== 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=VGQ6L3EDR/BqCH8CZudbym0SFjzw+T3VOUjSdHU+7O8=; b=xImfuQPGg48T9gbgTRwEq92AfSztlKlhfIiUEKTbLktTofJIjcI3WVgFKkydzy+gwu p+mdmJJoAfssZYb8/efu3PtVqsIWqh5Hyv56nk67cqy6espcQAhMAqVy3hU2PPz+QKLI vJRWDNETgEyR+SblmYk0QNr6pm6fYT8PuRjUqecZ8ql5nRg0gF/pS/NPC6u5f8WypNnd uEyThgkTbK69XJ7iAwHU6EPs0XyakmK5YpLKYC3z8ud6mk3t3MxrLtCqZAC1Jbee3Ni4 pHzdacae8WtGJ2ELVtnQERaO5de4c/y3NTE6uIZuNcoaG9HhIU5Rufh7tVgBFK5jbGAJ YcSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CqiQ2nSr; 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 d14-v6si21441005pls.333.2018.05.24.03.43.03; Thu, 24 May 2018 03:43:18 -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=CqiQ2nSr; 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 S1030626AbeEXJ6a (ORCPT + 99 others); Thu, 24 May 2018 05:58:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030466AbeEXJ6W (ORCPT ); Thu, 24 May 2018 05:58:22 -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 E7F8A20870; Thu, 24 May 2018 09:58:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155901; bh=2e87+7YefHoI0au8xSSYhtshrQMa2rQGZWP+hu659tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CqiQ2nSr2xwBPtHlkebEK1Im/rxa2kFArB+CHAW/xugUjBmi3KlS/PmfXpgjYXjUy to5azR7Ee6xi1nziYia8qpjTxKfZxgns2pWDHqe6WCDxfwv+HcMZHNJ18UcHuwGS5f MVGuCHugna/5VeDUHARevYxVx51W+cMC5iaINaUg= 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.14 151/165] serial: sh-sci: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:17 +0200 Message-Id: <20180524093628.187290948@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 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 @@ -3076,6 +3076,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;