Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1922283imm; Thu, 24 May 2018 03:00:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvHjaQlyJn+gGyBwBQOD/Xq60+HZrmp0gN8cMzd/fDCepcXRlaxFonWMqKzQS4OSP9ss9s X-Received: by 2002:a62:d751:: with SMTP id v17-v6mr6517814pfl.39.1527156012252; Thu, 24 May 2018 03:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156012; cv=none; d=google.com; s=arc-20160816; b=l812KTL8bnt5ah0NB6NdHFeFetAB6cwctkDTdkpsXUsvru8GDM/ZsqKEw9tt2VPRFz 05d1owBDVfTHobycPpP0OW5Ef/WC7RoT4wWYUnfFVDQemXJ28ij04QCsKRF54FsZ6jWs s8xM4ia5hhx8OAXzR4HLIlKmKlhMy+zdg69HI+U3A3lMUwSwJ+ArSwBsp1Vb10qSHuuJ jmOPxkAc6cFmyaItIAm0r82hkJYEvhyIwqJSOZ2hlRzBBUy7CB24CTwNa+KLxv3fKIh7 7Jn6WLR787BNAtpcxKQtGSfAXAuJUVDCOEb+reaWyrrRPQ25HU/tmTkf4V5oUDQV4RyD z76Q== 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=snNWrHMJUdMG6lnNA0R9NC808IQ75kYMNGvYxJWerNU=; b=x0F7MT5PgdlrpFfqDg1pixVGdy1buu82fMSfQhkFIJce+nolvFuqGaJKkxgdmJyqxf 9gTsEaAF30h9Q2ou727vfJk3G1X70Uzyg8VHmhwvy1+EjnOlHdc7sbrCh7rxYlr3BlW2 VBgyLQdJXf7prQdk9WcmCf7qMj+2GlXDEtw/MCDUVi6qeGhf/EdigYV9LqHxrHLmvNQ7 p1EqdSvjCVe4W642j9jEA6m2yGlhkGeNvvkgyliGJvptELsyTcuLyPnfKP8QwYrGdIaL 4oeIWPL7gtZXETJOfhAQ/4znV0JFGgVeRgLqfwP8eA1NZiJwgNSMK3xI56jbYDJIdCPI ihww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B98z3hoy; 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 k127-v6si16207842pgk.256.2018.05.24.02.59.57; Thu, 24 May 2018 03:00:12 -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=B98z3hoy; 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 S1030705AbeEXJ66 (ORCPT + 99 others); Thu, 24 May 2018 05:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030662AbeEXJ6w (ORCPT ); Thu, 24 May 2018 05:58:52 -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 2EC452088E; Thu, 24 May 2018 09:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155931; bh=q47nR68gPquXXJB5sf0e1ePGbh3Izl6k8IXcikyzeGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B98z3hoyeb/f0C7F8ozJ1YbfNwHKsS+LRWiQGL/IR0KQ0vei6YSAmR8Td8+faNAdc ckg91QfwuBFdP1Ru/zYmPTw/e+J/0JhMPmw7Jf/mooSoNvdAbtzdrWZSLrUqJqoLIg Xu7zWognAFDzuaCxrwtCH3y7JtOkodDPJl0vgRxI= 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 156/165] serial: arc_uart: Fix out-of-bounds access through DT alias Date: Thu, 24 May 2018 11:39:22 +0200 Message-Id: <20180524093628.387579696@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 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;