]> www.infradead.org Git - users/jedix/linux-maple.git/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)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 Nov 2024 15:54:11 +0000 (10:54 -0500)
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
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

index eac92130c0be6fea3892f0947414850dfc391794..9da4414de6177de8245c090d41d263983d9df58f 100644 (file)
@@ -402,7 +402,7 @@ static ssize_t amdgpu_debugfs_gprwave_read(struct file *f, char __user *buf, siz
        int r;
        uint32_t *data, x;
 
-       if (size & 0x3 || *pos & 0x3)
+       if (size > 4096 || size & 0x3 || *pos & 0x3)
                return -EINVAL;
 
        r = pm_runtime_get_sync(adev_to_drm(adev)->dev);