]> git.hungrycats.org Git - linux/commitdiff
drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 23 Oct 2024 20:52:08 +0000 (16:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Nov 2024 13:59:36 +0000 (14:59 +0100)
commit 4d75b9468021c73108b4439794d69e892b1d24e3 upstream.

Avoid a possible buffer overflow if size is larger than 4K.

Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f5d873f5825b40d886d03bd2aede91d4cf002434)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

index 8a1cb1de2b13aee97a8fd6f0e07e9b70dec08377..3cca007a0cd079497a621fbd12a47b05449ff148 100644 (file)
@@ -396,7 +396,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
        ssize_t result = 0;
        int r;
 
-       if (size & 0x3 || *pos & 0x3)
+       if (size > 4096 || size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
        r = pm_runtime_get_sync(adev_to_drm(adev)->dev);