]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/amdgpu: Fix bounds checking in amdgpu_ras_is_supported()
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 8 Jun 2019 09:23:57 +0000 (12:23 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 13 Jun 2019 01:39:48 +0000 (20:39 -0500)
The "block" variable can be set by the user through debugfs, so it can
be quite large which leads to shift wrapping here.  This means we report
a "block" as supported when it's not, and that leads to array overflows
later on.

This bug is not really a security issue in real life, because debugfs is
generally root only.

Fixes: 36ea1bd2d084 ("drm/amdgpu: add debugfs ctrl node")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h

index eaef5edefc347e4a04b492548b72b0966236db99..24c6e5fcda8660316f5a289c38c95e32c75de6df 100644 (file)
@@ -172,6 +172,8 @@ static inline int amdgpu_ras_is_supported(struct amdgpu_device *adev,
 {
        struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
+       if (block >= AMDGPU_RAS_BLOCK_COUNT)
+               return 0;
        return ras && (ras->supported & (1 << block));
 }