Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4131502ybi; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSIOF2aZfBcBDiNnX7DZsX3gyeWKgmewoYdj2mZ/5RhIqSxkyfiRQNH4ZfDeQEsao2Kexk X-Received: by 2002:a63:b555:: with SMTP id u21mr108820041pgo.222.1564455455408; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564455455; cv=none; d=google.com; s=arc-20160816; b=B5Ee+AlMWfAj3Lf8nwzWkCZ4yuTV3HxuW5qc+dHsWqQIenFjg5FuOlMz+K2ury1yFS pnt+nOAZ8uaYQ6G7jEsxmf9IuAgqq4UeVvMfA/nJ8mddkILmFy2VQwVFGdZ8WoiLixZB 7wWKMPRjvjcsmOB27z4k6HglAB4L2AYtMusxOs3w749ZPz+DYbKhKIQ214Jqz96r+oxU D6Tu8PVpJSeRu+PJdfsSs3QdqbkepBvFKT7cmbOgs5Xq28KAUNj7T9diLfGeNr8+enN3 r1d7MhnMUK2vPULzVHnbI3NEjvA4wK8+mmYFp3asEJ8qxkAU7pDOjnJ5EXlg16IDiBZ+ VS9g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6YDTaY+E12b3hSAcr+mo7hLK76IT1KcsZOOVAaxWGXc=; b=u0YgSMUSZin72tHttPm5CSKLfVtfkyNw4vrf5aRDxRl6IYauGjrMbY6usQa2z7g1UK fz8xgB5NxoY+4Chp6X8q1Pu2CHXLwlhQ1KT2hhxjxx6k0thkjGiYx0rhY6iZ0yE3IR33 LlDR4+ztRLthum/KnjZH277qPJmrMl5tf7cVrfGyLtDIuFk8TrnQwoe4M9ASi/hvqHvx 5gVvk4ngOmhIzZKmqx6pfQ6kA/j6gewNgrx/0Ss5xrbRI3iyjjhSYiL94QP0gC2oR1Jn dOzbBMOKyQKNmAP461Y0c1k/VqrMn6r52RxmBNYPcUqbUels3XklNjcCz7cRUNL0chtt aUsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EMz+W7Z5; 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 a5si28413172pgw.454.2019.07.29.19.57.01; Mon, 29 Jul 2019 19:57:35 -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=EMz+W7Z5; 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 S2390360AbfG2Tuq (ORCPT + 99 others); Mon, 29 Jul 2019 15:50:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:41760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403822AbfG2Tuo (ORCPT ); Mon, 29 Jul 2019 15:50:44 -0400 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 70DEF2054F; Mon, 29 Jul 2019 19:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429843; bh=SLoCrE+l3z1bj2/xRj9SHLZmNuZjXvDISzhJ4Qw/hkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EMz+W7Z5FPeUeCm8meKe2thgmvrYPcOl9e06T86YBQBZfdA0kZlHK2kzThsas5Tdz 6el7BA/xPPUYEV2xjUQ6RFrCdbAcO8jBf13SXPqN1YhNNxZVN7/oJASKmWU22eOn9v w2HeQxV0SfVI4M9Wn16XHHOn4v13zEzFa5YGFEHo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordan Crouse , Bjorn Andersson , Jeffrey Hugo , Rob Clark , Sasha Levin Subject: [PATCH 5.2 076/215] drm/msm/adreno: Ensure that the zap shader region is big enough Date: Mon, 29 Jul 2019 21:21:12 +0200 Message-Id: <20190729190753.184172489@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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