aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-06-29 07:26:41 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-07-07 15:06:09 -0400
commitb5f5acbc87052e1bd8ada6915e1dedd856da767d (patch)
tree0892fd1a08ab03f5ff5fc074685c8294ba34166f /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
parent566281595037a6f5932adbf8e04d3a63e7687fd7 (diff)
drm/amdgpu: fix user fence handling once more
Same problem as with the VM page tables. The user fence address must be determined before the job is scheduled, not when the IB is executed. This fixes a security problem where user fences could be used to overwrite any part of VRAM. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 95b248159947..475c95f670f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -216,11 +216,8 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
216 if (ret) 216 if (ret)
217 goto free_all_kdata; 217 goto free_all_kdata;
218 218
219 if (p->uf_entry.robj) { 219 if (p->uf_entry.robj)
220 p->job->uf_bo = amdgpu_bo_ref(p->uf_entry.robj); 220 p->job->uf_addr = uf_offset;
221 p->job->uf_offset = uf_offset;
222 }
223
224 kfree(chunk_array); 221 kfree(chunk_array);
225 return 0; 222 return 0;
226 223
@@ -502,6 +499,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
502 } 499 }
503 } 500 }
504 501
502 if (p->uf_entry.robj)
503 p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj);
504
505error_validate: 505error_validate:
506 if (r) { 506 if (r) {
507 amdgpu_vm_move_pt_bos_in_lru(p->adev, &fpriv->vm); 507 amdgpu_vm_move_pt_bos_in_lru(p->adev, &fpriv->vm);
@@ -767,7 +767,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
767 } 767 }
768 768
769 /* UVD & VCE fw doesn't support user fences */ 769 /* UVD & VCE fw doesn't support user fences */
770 if (parser->job->uf_bo && ( 770 if (parser->job->uf_addr && (
771 parser->job->ring->type == AMDGPU_RING_TYPE_UVD || 771 parser->job->ring->type == AMDGPU_RING_TYPE_UVD ||
772 parser->job->ring->type == AMDGPU_RING_TYPE_VCE)) 772 parser->job->ring->type == AMDGPU_RING_TYPE_VCE))
773 return -EINVAL; 773 return -EINVAL;