Skip to contentSkip to conversation

drm/amdgpu: fix potential double drop fence reference

PATCH Applied Pan Bian 3 participants 3 messages Nov 6, 2019

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix potential double drop fence reference

The object fence is not set to NULL after its reference is dropped. As a result, its reference may be dropped again if error occurs after that, which may lead to a use after free bug. To avoid the issue, fence is explicitly set to NULL after dropping its reference.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -0
index b66d29d5ffa2..b158230af8db 100644
@@ -138,6 +138,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 		}
 
 		dma_fence_put(fence);
+		fence = NULL;
 
 		r = amdgpu_bo_kmap(vram_obj, &vram_map);
 		if (r) {
@@ -183,6 +184,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
 		}
 
 		dma_fence_put(fence);
+		fence = NULL;
 
 		r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
 		if (r) {
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw

Am 06.11.19 um 10:14 schrieb Pan Bian:

Quoted 6 lines

The object fence is not set to NULL after its reference is dropped. As a result, its reference may be dropped again if error occurs after that, which may lead to a use after free bug. To avoid the issue, fence is explicitly set to NULL after dropping its reference.

Quoted 24 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -0
index b66d29d5ffa2..b158230af8db 100644
@@ -138,6 +138,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		}
 
  		dma_fence_put(fence);
+		fence = NULL;
 
  		r = amdgpu_bo_kmap(vram_obj, &vram_map);
  		if (r) {
@@ -183,6 +184,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
  		}
 
  		dma_fence_put(fence);
+		fence = NULL;
 
  		r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
  		if (r) {
Applied
#2 lore raw
Quoted 10 lines · Christian

Am 06.11.19 um 10:14 schrieb Pan Bian:

Quoted 6 lines

The object fence is not set to NULL after its reference is dropped. As a result, its reference may be dropped again if error occurs after that, which may lead to a use after free bug. To avoid the issue, fence is explicitly set to NULL after dropping its reference.

Applied. thanks!

Alex

Quoted 23 lines
Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +2 -0
index b66d29d5ffa2..b158230af8db 100644
@@ -138,6 +138,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
              }
 
              dma_fence_put(fence);
+             fence = NULL;
 
              r = amdgpu_bo_kmap(vram_obj, &vram_map);
              if (r) {
@@ -183,6 +184,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
              }
 
              dma_fence_put(fence);
+             fence = NULL;
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_test.c static void amdgpu_do_test_moves(struct amdgpu_device *adev) · line 190

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +0 -0
              r = amdgpu_bo_kmap(gtt_obj[i], &gtt_map);
              if (r) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel