From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 19ED2C2BA83 for ; Fri, 14 Feb 2020 17:11:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE1FF20637 for ; Fri, 14 Feb 2020 17:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581700282; bh=VolOWGt8Y6RcvUk2MXjC8VbXcBD/ECMXJzfRWU78h58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=JC3NvVosVmah91LFoIWsatIskIOvoteqEbx0SVz7SneAsWdaVrjDehXOWBVtBSXKQ 7iGoDkg3eQouCpwepnYmaIfEFcK8jVj4c67HRFAvBoYApxnpnBWjj77FK4kfFwjXkF WLBucyJcOrbBfp3nZM+OGFqoWEaoIuyGeBTI/0Z0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404401AbgBNRLV (ORCPT ); Fri, 14 Feb 2020 12:11:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:41954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403866AbgBNQN2 (ORCPT ); Fri, 14 Feb 2020 11:13:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9414C246CC; Fri, 14 Feb 2020 16:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581696806; bh=VolOWGt8Y6RcvUk2MXjC8VbXcBD/ECMXJzfRWU78h58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZB0AL/5HMGCDvBqCTVx0pp1GOnG4p8OSQ2gqDBDSfp48no4ecKugDMl3oqxY2JFp FszuwxxTvzdyXjLb2L9HytguPm9vu/Ktj9+zls6H8t1v2k6k/+46sw1c/tQO6kJAjn pZPz+k498c1intLEjuWWQmO96UuocSNEgQsQDZwU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rasmus Villemoes , Qiang Zhao , Timur Tabi , "David S . Miller" , Li Yang , Sasha Levin , netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 077/252] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K Date: Fri, 14 Feb 2020 11:08:52 -0500 Message-Id: <20200214161147.15842-77-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214161147.15842-1-sashal@kernel.org> References: <20200214161147.15842-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 daeab33f623e7..9ab04ef532f34 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -242,6 +242,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); -- 2.20.1