Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3132194ybi; Thu, 18 Jul 2019 21:39:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqytmYkxDi2jvK5SWTlKL07n1bEtjR41WarMXGvEv6sWRwwmp/pqRG+V+DDUkR5DasAFTqs6 X-Received: by 2002:a17:902:b70c:: with SMTP id d12mr52473986pls.314.1563511172748; Thu, 18 Jul 2019 21:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511172; cv=none; d=google.com; s=arc-20160816; b=okD7GrMf0klABXP277rKItILwVWpY8N1ARuX/swcQ09OoGfMhlsPa2H7+DaD87jS9D isnWBW3BdhZ6KnScYn2UHr5hm//ZjlQyBbaVo1ckXZYdJpHD7gmQIIEeylSlisXnzCsU RZcBwZnXYld/wk6P1iphgf1LKlm7yPbbtBUD/kKhOAaHwJ/byffqEDUIs75B8EEpwUv1 VzXTFRa0FXYZuhqInwr3tE/kcDbrojRLDueeUrznJ4hdf3z361mw3DcOue2ZkDe7SufF L/aGR3IAh1ipBQRPEmgJpw13HFRTmRxsfYpwcd2aOnIeUI9W1oS1dNgepXm9mhofI+tu b3Rw== 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=+d9a9rr6bBCnpzrJ3/o9Mh8/XAzK8qCxPR1VHHWI/4s=; b=fWc7bZbBFt/nvc+2WIGgYIuiTxveqgEAEhZm9EahzJwT+6TsD7+PyQq+trX5Q7Wf+v nMbIFA+1rks7O1XN0g6DwpyFUy5zqilXb3lrvmviJMpcBNPmKPt7CCWAc/bLyK6UyJ6z cqVOIBVFjqfM24lRAzZ8cSav4IkwvENfEKAulImMgqE1IqT6SdaURPRnOgwDFnmqyy1d wBxBRUts5051ICDQU773IoZoiRCc74Wt+59fy+l1qxbUi5PR4iTwDGqv6ICEMWPcKO9n 5qDGKeCXgCbTcnZDcPkPhsygNpfcKTjazsVtne8NVnZ8fGdhiWyZJAKFpWALK8kRHHVm 95MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YeS6kzXV; 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 t4si2640502pjr.31.2019.07.18.21.39.17; Thu, 18 Jul 2019 21:39:32 -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=YeS6kzXV; 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 S1728715AbfGSD71 (ORCPT + 99 others); Thu, 18 Jul 2019 23:59:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:58944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbfGSD7Y (ORCPT ); Thu, 18 Jul 2019 23:59:24 -0400 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 2212F2189E; Fri, 19 Jul 2019 03:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508763; bh=dhxt8vrEK/YOQ/s69fnoSZf6HqR0cV3OukQKYT12Uq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YeS6kzXV6Qw09mpw5SCui6FwlyXHpBna91RX0X7aI1mk+PzIDH2W4IoF4pRKkpKu6 WmPdWZ9D82UuRxE7ah/RSYGiJAFB+ZpxLfCtuivYWp/w4LqeXhl8/g1qLQgOddF+4N UOOxinn+JomDKXSwvgNbhn90HzxwmS6FDaOVfVVo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jordan Crouse , Bjorn Andersson , Jeffrey Hugo , Rob Clark , Sasha Levin , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.2 076/171] drm/msm/adreno: Ensure that the zap shader region is big enough Date: Thu, 18 Jul 2019 23:55:07 -0400 Message-Id: <20190719035643.14300-76-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-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: Jordan Crouse [ Upstream commit 6672e11cad662ce6631e04c38f92a140a99c042c ] Before loading the zap shader we should ensure that the reserved memory region is big enough to hold the loaded file. Signed-off-by: Jordan Crouse Reviewed-by: Bjorn Andersson Reviewed-by: Jeffrey Hugo Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index a9c0ac937b00..9acbbc0f3232 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -56,7 +56,6 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, return ret; mem_phys = r.start; - mem_size = resource_size(&r); /* Request the MDT file for the firmware */ fw = adreno_request_fw(to_adreno_gpu(gpu), fwname); @@ -72,6 +71,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, goto out; } + if (mem_size > resource_size(&r)) { + DRM_DEV_ERROR(dev, + "memory region is too small to load the MDT\n"); + ret = -E2BIG; + goto out; + } + /* Allocate memory for the firmware image */ mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC); if (!mem_region) { -- 2.20.1