Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2089901ybp; Thu, 10 Oct 2019 02:01:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZFfVdLYdiRnHBa3Wf6EmK4PpK9OH7/n7a8DF1jCyV7Zp3veIs21XbzFqw+wRc6xcmfRUu X-Received: by 2002:a17:906:4d5a:: with SMTP id b26mr7018776ejv.157.1570698082042; Thu, 10 Oct 2019 02:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698082; cv=none; d=google.com; s=arc-20160816; b=tlkRjQimq7/WTB/NH8DYEjW+iB2PIYIJYUMlcj/WNV8P/7Gg7oJ8q0A20knQ0ztldD o8K70VSIZstOdbgLeY3p+F2u6NhoHZrajifXHusPcfZcDKI4Ask1aYPBTtIa76cew8yf 8GrkeYWzjCOTmwJNGl+KQU1r4PZwSo4z21EQNOpxOdOTq4hW985uJQIRQVJoiAym3jpS JPEpj5f98cMoMCRSLzkdZZFtUIkYPG4aEr2st7pFOpo7SNyQ3sH1pf+ODn8VUp1DxizW g74PSSBC0KPnRxrQ5wsQoKxf8keUBsQKUaWyeXe87v6KMhrhqltpZDtIpTgGekuIKsXz MQOg== 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=DQdJhC+33TkWbFGqwotB1QYXx/cufP4pl6eKMdVCwSs=; b=jw3yenDOtKZPyMz/3V4SDDXvbFeDXq5MftlBTzDAxICIBmgFVFRvyqG4RgzXbz92bA N0yEdc2tpty6ajqVZDTB9C9OJH7+Z+YLdfuGEo9pr7mWW84mBuRHQkIAga4ijDBzPDpS V5Ag/AwX7EEDh8Ep3TIjckNdTtKx2wSnn5zigNHBXGdaHVCpknd+mwp5q9mR4+LCi/7m FAPG//9OX6YZ/Ufc7euKK/Z/kBhb47RNzempVicPsv0jr/BsCwDARml/gyk+5o689Stk eBdbOwlly+s6bW2cSINioX+/S4car5tubLcicTrbhdDi87Hf11LX/Ie87WdhgX5EZCYK SXDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QcEymdV8; 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 w12si2785254edx.223.2019.10.10.02.00.59; Thu, 10 Oct 2019 02:01:22 -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=QcEymdV8; 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 S2388501AbfJJImN (ORCPT + 99 others); Thu, 10 Oct 2019 04:42:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:46730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388494AbfJJImL (ORCPT ); Thu, 10 Oct 2019 04:42:11 -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 AA0102190F; Thu, 10 Oct 2019 08:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696931; bh=67alXanO7YCIs4Cnpue3J69QNuYSm8158GPO0Zhsjto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QcEymdV8TKr927JjQAxx2tPv5HNcT6xEJB5xcGTEGoyDrvdkcJuVv3e01brHdglwq ZvftmJpqHWkLa5JiimWb1b86lmg3SxkE/Mf1Jf/tNJGyTKMFUf1EwyBtKNmbXAKvK3 H7oMWN//S2I5dIkItLwm/BfmaW+xDqrgvaNdIKr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trek , Alex Deucher , Sasha Levin Subject: [PATCH 5.3 105/148] drm/amdgpu: Check for valid number of registers to read Date: Thu, 10 Oct 2019 10:36:06 +0200 Message-Id: <20191010083617.557758906@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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 From: Trek [ Upstream commit 73d8e6c7b841d9bf298c8928f228fb433676635c ] Do not try to allocate any amount of memory requested by the user. Instead limit it to 128 registers. Actually the longest series of consecutive allowed registers are 48, mmGB_TILE_MODE0-31 and mmGB_MACROTILE_MODE0-15 (0x2644-0x2673). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=111273 Signed-off-by: Trek Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 0cf7e8606fd3d..00beba533582c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -662,6 +662,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK) sh_num = 0xffffffff; + if (info->read_mmr_reg.count > 128) + return -EINVAL; + regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL); if (!regs) return -ENOMEM; -- 2.20.1