Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2485195ybx; Fri, 8 Nov 2019 05:06:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxX7cJcIq0NlqANFbQrjYWlKWgM9opfkskvbwY8u/sZTLJ5kCr/3J2a2yTAqNIlIoin3RYF X-Received: by 2002:a05:6402:1b90:: with SMTP id cc16mr10269803edb.304.1573218361178; Fri, 08 Nov 2019 05:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573218361; cv=none; d=google.com; s=arc-20160816; b=DgCuvscoMDi3Zz1xDFcEnrA1bEIvaLj+ps7HX+U7q09OqvbSEmYRUv+CyvpZbxoix4 pfEO867n5rDTGZ9e+qsURDz1ktAW0SnOn+39IWwqnmiSQLSWJMBg6tdrguCx//mz3t+k 9pa3FoXR3pz80jtLPNUUZFZf4KNJDp81ItlpxE8eKjDy/KiT7c0lx5uXu/eLzHnTVoPe Pd6R1Uqn7dZHWYK44EbhJux4PWzgvlrAOm7pRpjLoPt/JNbHMFmV1dERqL8ZWBqsVOVe bekPuikekgAWfIOpIzLdD0ekg9XjzzwCqAQP1aIxjrAV4Sa1AiVFViqNTXmZvM0D9Stg MgdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2QjvBFt/Ahp0rywmkIDhfkZ7dAuBAKpWua4zqIA54R0=; b=MsjERRdzkFLzA5yt9sWm/IgNjIewWNRriPTMIVwvAS7TzQTamKtmgfOan6nAi0TQMX U7sMkuuBQ4LT8ZwbQGmzJgB9FoJUayDa3AsxuSOGcpfgeQW03KkjD0Te9UklPgd7oCMg 1ypZOsF3dah4f5ywZgHkCQP+SnLrCHPRw6mpbMEpct0YXbkvij3F+B3M25YcJauAU4L4 h3KKmWIVNIccbmUVP62aKnWvICZwzrRm6kuKKAoDIWrKRQ3VRQR2J0/Od5Spgynj1w6L qEfQjwl9EQ6qtlxv+9lBxtiF5u6c0V1V1IsY/+XD9BQD1jtCHZDBP/2NnnxAUtZ7WCsZ 0rMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=XVACoOOu; 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 g31si3868200edg.206.2019.11.08.05.05.37; Fri, 08 Nov 2019 05:06:01 -0800 (PST) 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=@rasmusvillemoes.dk header.s=google header.b=XVACoOOu; 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 S1730780AbfKHNDD (ORCPT + 99 others); Fri, 8 Nov 2019 08:03:03 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34255 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730799AbfKHNCZ (ORCPT ); Fri, 8 Nov 2019 08:02:25 -0500 Received: by mail-lf1-f68.google.com with SMTP id f5so4431846lfp.1 for ; Fri, 08 Nov 2019 05:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2QjvBFt/Ahp0rywmkIDhfkZ7dAuBAKpWua4zqIA54R0=; b=XVACoOOuXlxl4Cy3V/J8sGSeCCFw8ZKOKZ7FqB/K3JgCxUCJ1xCj/Mqawr8e2qIujx O7k1zBR8675/UVFNVWJud7B7gGy4eRxvGFDaQiIdBxLuh/UvxbGJ2jiZIbbPNPtq2kf0 ZABUDJvpYchPCeIhdPhVBPmgejb6251Cuy5iE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2QjvBFt/Ahp0rywmkIDhfkZ7dAuBAKpWua4zqIA54R0=; b=VRhwAVMXgidrgP9FUMsPJR63Uk2Tzk0X/msf1a/rcHgpVtFYskj4djQKuWkb/pgdj0 LO/XQwDAu07+dLv35XyFQaaUhRCbRP7rm6WWvbfgQQIzRSOqFWUcwQuGIrpxGuExZzRF 2OtXky2FGwB8t6SUj8pkIxWHbygSjhYtBlrIyTyXFajW+yqJAHsogyc4emQxJ3k+ZMWi 4eQdo2Dw+mI84GidphlLFe/fw/CksiBqbKBZOwIBwVRaRaRmHnlQsUZo2Jv/58wV7lmQ IlS88JMNApo2A4S0Oa83jFj5HPukkfPbRgFAqxdeGeRzqZZvNozopciVhwiuJ6PuCMdR /LfA== X-Gm-Message-State: APjAAAX/XiLwX4H1yNK5tFtqaj2IvmMXYOAQm6cWxvO920ZWa9HBC7aO KAK6zphIO3ob5U1J7zS0xXkaAQ== X-Received: by 2002:a19:820e:: with SMTP id e14mr6605403lfd.29.1573218143917; Fri, 08 Nov 2019 05:02:23 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id d28sm2454725lfn.33.2019.11.08.05.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 05:02:23 -0800 (PST) From: Rasmus Villemoes To: Qiang Zhao , Li Yang , Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Scott Wood , Rasmus Villemoes , netdev@vger.kernel.org Subject: [PATCH v4 45/47] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K Date: Fri, 8 Nov 2019 14:01:21 +0100 Message-Id: <20191108130123.6839-46-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108130123.6839-1-linux@rasmusvillemoes.dk> References: <20191108130123.6839-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Rasmus Villemoes --- 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 8d13586bb774..f029eaa7cfc0 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -245,6 +245,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.23.0