]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()
authorPeilin Ye <yepeilin.cs@gmail.com>
Tue, 28 Jul 2020 19:29:24 +0000 (15:29 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Jul 2020 15:02:10 +0000 (11:02 -0400)
Compiler leaves a 4-byte hole near the end of `dev_info`, causing
amdgpu_info_ioctl() to copy uninitialized kernel stack memory to userspace
when `size` is greater than 356.

In 2015 we tried to fix this issue by doing `= {};` on `dev_info`, which
unfortunately does not initialize that 4-byte hole. Fix it by using
memset() instead.

Cc: stable@vger.kernel.org
Fixes: c193fa91b918 ("drm/amdgpu: information leak in amdgpu_info_ioctl()")
Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index d7e17e34fee171a2d103fe79a2fc27ac9d68c95c..21292098bc023d09b29470b20b66261510eba765 100644 (file)
@@ -692,9 +692,10 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                return n ? -EFAULT : 0;
        }
        case AMDGPU_INFO_DEV_INFO: {
-               struct drm_amdgpu_info_device dev_info = {};
+               struct drm_amdgpu_info_device dev_info;
                uint64_t vm_size;
 
+               memset(&dev_info, 0, sizeof(dev_info));
                dev_info.device_id = dev->pdev->device;
                dev_info.chip_rev = adev->rev_id;
                dev_info.external_rev = adev->external_rev_id;