Commit 8ea180f1c7ec137310ea2e66300485dbda93baad

Authored by Peilin Ye
Committed by Greg Kroah-Hartman
1 parent f1b4bdde2b

drm/amdgpu: Prevent kernel-infoleak in amdgpu_info_ioctl()

commit 543e8669ed9bfb30545fd52bc0e047ca4df7fb31 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
... ... @@ -667,9 +667,10 @@
667 667 return n ? -EFAULT : 0;
668 668 }
669 669 case AMDGPU_INFO_DEV_INFO: {
670   - struct drm_amdgpu_info_device dev_info = {};
  670 + struct drm_amdgpu_info_device dev_info;
671 671 uint64_t vm_size;
672 672  
  673 + memset(&dev_info, 0, sizeof(dev_info));
673 674 dev_info.device_id = dev->pdev->device;
674 675 dev_info.chip_rev = adev->rev_id;
675 676 dev_info.external_rev = adev->external_rev_id;