From patchwork Thu Feb 27 13:34:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 230205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0F77C76561 for ; Thu, 27 Feb 2020 14:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C7E52469F for ; Thu, 27 Feb 2020 14:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582814323; bh=Zmrtpa0LZihMZl3Ce8bNs5Bu/r1pFub2fc8hCI01eR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TlvRZuC6bPM4c5eCD4UqPrBgPSMvxYXDGIQYRUo9gyDeezk4yD6z6f/sjxazs56RG Unj1IvL/WhYd0YIqrR0T9RdjJdXKe4cgvB+TYBARZM+yh3ER8+XBGYKunzRRAz5z9I 68xS5yUOJXnU7PIHln9NIMklX8lAhXhhW0V9AoxE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732060AbgB0N4A (ORCPT ); Thu, 27 Feb 2020 08:56:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:56400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732056AbgB0N4A (ORCPT ); Thu, 27 Feb 2020 08:56:00 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 12B6721D7E; Thu, 27 Feb 2020 13:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582811759; bh=Zmrtpa0LZihMZl3Ce8bNs5Bu/r1pFub2fc8hCI01eR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bUXUds///jULaZJhlol2A0R0NHtKfxWDS9EzIF2eXuZFMJAHKyQL40zL6RriRU6Og YtzBrLH2tzbRYRWL2GuO44Mo+7Lf89JtVn94TMJFOvUdzBp0q6YGIEXuAHg95lbYNV gwdhoNibODw7EaXpB50icHrXNDt0kgC8RJ+fLmTY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiang Zhao , Timur Tabi , Rasmus Villemoes , "David S. Miller" , Li Yang , Sasha Levin Subject: [PATCH 4.14 073/237] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K Date: Thu, 27 Feb 2020 14:34:47 +0100 Message-Id: <20200227132302.512954966@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132255.285644406@linuxfoundation.org> References: <20200227132255.285644406@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rasmus Villemoes [ Upstream commit 148587a59f6b85831695e0497d9dd1af5f0495af ] Qiang Zhao points out that these offsets get written to 16-bit registers, and there are some QE platforms with more than 64K muram. So it is possible that qe_muram_alloc() gives us an allocation that can't actually be used by the hardware, so detect and reject that. Reported-by: Qiang Zhao Reviewed-by: Timur Tabi Signed-off-by: Rasmus Villemoes Acked-by: David S. Miller Signed-off-by: Li Yang Signed-off-by: Sasha Levin --- drivers/net/wan/fsl_ucc_hdlc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 571a1ff8f81f2..6a26cef621935 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -240,6 +240,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) ret = -ENOMEM; goto free_riptr; } + if (riptr != (u16)riptr || tiptr != (u16)tiptr) { + dev_err(priv->dev, "MURAM allocation out of addressable range\n"); + ret = -ENOMEM; + goto free_tiptr; + } /* Set RIPTR, TIPTR */ iowrite16be(riptr, &priv->ucc_pram->riptr);