Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1930175ybv; Fri, 14 Feb 2020 08:24:49 -0800 (PST) X-Google-Smtp-Source: APXvYqw9vjvqmPFxgwNuYmwlSh88Z83ldzTkW905C+EGTE6LW+njSVDcHf3UuHYk6otsrtl3Ehdj X-Received: by 2002:a9d:811:: with SMTP id 17mr3030133oty.369.1581697488943; Fri, 14 Feb 2020 08:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697488; cv=none; d=google.com; s=arc-20160816; b=fWvkSfEuu1Xxk2TJlK3Ih709OIhgHN09jWXg8a4rh/g12sCJKCUo8vb+tFFk3lborO GmOXXcZnP1S8AkvpS0TwHPSoKEEjMrUxXP1H98rviMm/Gyor/ciTkeuBl67BGFl4bIeo lDi1Jahsyvl+kRJPY4fhuXm4ql9jzdKTdPImlNXPpecH6gB18hAp9Jrk44dXrr4md9+5 uCP1RDq1M05fdHH0tl2JSNWQ9vtHMPzmWX9puILgl10ZpHPpCzZ/OB+UmbwjjMDys/78 inSd5XP4jt22PDklmh1KcJe1sFk3Y26a7XlztZTQp9kdX8V6CJHDIRvSjmb33FV124Y9 dLVQ== 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=Mrl4nSO9Dsea1dP7tczz1lCDn8TDhwPUKfA4QGEw1Rk=; b=B0lFqa78OXCRjWx8/w0QuJ710ZCAKPVtErNypPyNudRpNwSfFUmY9pJOktwQSpNNnF L2KhKQ2oUlVVvSBjNR7ZxMEkej3g7I8LPps3a9Rlre6QnIvraCHG//3/tzVXIa3948Tn xnjkQFiTlodmZjUPBHcM+cxF3UICLtMRPZGKhpychYgYR67RN0lyRx6ASEmClZBJzzgA OTvxWeqFZz5ofqukWOZ2HadU/A2DHJ4Vxq1ED89AZHtf4s3crIpVKewNRO1ccx777Ikf IlTTP26GNJUvvrx+h27Fg1JjuFbMZK5hEv9/+CwxcB0UsBIBYn5ghBL+PrXLGE/O7U5Q PCWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=InhpFNCP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si2882423oib.59.2020.02.14.08.24.37; Fri, 14 Feb 2020 08:24:48 -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=@kernel.org header.s=default header.b=InhpFNCP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404582AbgBNQYI (ORCPT + 99 others); Fri, 14 Feb 2020 11:24:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:57906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393217AbgBNQWZ (ORCPT ); Fri, 14 Feb 2020 11:22:25 -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 BACF72474D; Fri, 14 Feb 2020 16:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697344; bh=UO55tRwkGBNUjjrj++FD29xVqIkGuWGsESnDe4rEb70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=InhpFNCPOznifp4nrgSwOUceFRsCPWcCVAFkykuAmTKOb+MpIZFOUwgr7i5tUnxwf SZ75ZPTys09SYH1J1IGNKZrmP6vJ46cexUr77yktQUlNlsNNUROC2HGvDZKkz2TH17 kQye9uyyphoHy+L9R+ntAdOto19SjS/rLf3igiBg= 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.9 049/141] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K Date: Fri, 14 Feb 2020 11:19:49 -0500 Message-Id: <20200214162122.19794-49-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-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 af85a1b3135e2..87bf05a81db50 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -209,6 +209,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