Skip to content

Commit 8f2e3c7

Browse files
trek00gregkh
authored andcommitted
drm/amdgpu: Check for valid number of registers to read
[ Upstream commit 73d8e6c ] 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 <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 60991fe commit 8f2e3c7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
430430
if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
431431
sh_num = 0xffffffff;
432432

433+
if (info->read_mmr_reg.count > 128)
434+
return -EINVAL;
435+
433436
regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL);
434437
if (!regs)
435438
return -ENOMEM;

0 commit comments

Comments
 (0)