From 03c5ef195df4972d864d84c0ffaf917505afc13d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 27 Jun 2017 19:32:48 +0200 Subject: [PATCH] gallium/radeon: disallow exports of sparse and suballocated BOs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I think it's unsafe, because the slabs can reuse exported storage. Reviewed-by: Nicolai Hähnle --- src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 7 +++---- src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index a86cc2c248a..5119d3f5525 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -1365,10 +1365,9 @@ static bool amdgpu_bo_get_handle(struct pb_buffer *buffer, enum amdgpu_bo_handle_type type; int r; - if (!bo->bo) { - offset += bo->va - bo->u.slab.real->va; - bo = bo->u.slab.real; - } + /* Don't allow exports of slab entries and sparse buffers. */ + if (!bo->bo) + return false; bo->u.real.use_reusable_pool = false; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index e79c2b7da47..0354e200ebf 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -1290,10 +1290,9 @@ static bool radeon_winsys_bo_get_handle(struct pb_buffer *buffer, struct radeon_bo *bo = radeon_bo(buffer); struct radeon_drm_winsys *ws = bo->rws; - if (!bo->handle) { - offset += bo->va - bo->u.slab.real->va; - bo = bo->u.slab.real; - } + /* Don't allow exports of slab entries. */ + if (!bo->handle) + return false; memset(&flink, 0, sizeof(flink)); -- 2.30.2