drm/amdgpu: check alignment on CPU page for bo map
commit e3512fb670
upstream.
The page table of AMDGPU requires an alignment to CPU page so we should
check ioctl parameters for it. Return -EINVAL if some parameter is
unaligned to CPU page, instead of corrupt the page table sliently.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Xi Ruoyao <xry111@mengyan1223.wang>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
78ceecd2ed
commit
8c71f5b309
@ -2223,8 +2223,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
|
|||||||
uint64_t eaddr;
|
uint64_t eaddr;
|
||||||
|
|
||||||
/* validate the parameters */
|
/* validate the parameters */
|
||||||
if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK ||
|
if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK ||
|
||||||
size == 0 || size & AMDGPU_GPU_PAGE_MASK)
|
size == 0 || size & ~PAGE_MASK)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* make sure object fit at this offset */
|
/* make sure object fit at this offset */
|
||||||
@ -2289,8 +2289,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* validate the parameters */
|
/* validate the parameters */
|
||||||
if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK ||
|
if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK ||
|
||||||
size == 0 || size & AMDGPU_GPU_PAGE_MASK)
|
size == 0 || size & ~PAGE_MASK)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* make sure object fit at this offset */
|
/* make sure object fit at this offset */
|
||||||
|
Reference in New Issue
Block a user