Skip to contentSkip to conversation

dma-buf: Fix one use-after-free of fence

PATCH In review xinhui pan 3 participants 3 messages Jul 7, 2022 – Jul 28, 2022 DMA buffer sharing framework

lore
Share & tools
lore

xinhui pan

author
#0 lore raw

PATCH 1/1 dma-buf: Fix one use-after-free of fence

Need get the new fence when we replace the old one.

Fixes 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")
---
 drivers/dma-buf/dma-resv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-resv.c +1 -1
index 0cce6e4ec946..205acb2c744d 100644
@@ -343,7 +343,7 @@ void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
 		if (old->context != context)
 			continue;
 
-		dma_resv_list_set(list, i, replacement, usage);
+		dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
 		dma_fence_put(old);
 	}
 }
Signature · 1 line
2.34.1
maintainer
#1 lore raw

Am 07.07.22 um 10:02 schrieb xinhui pan:

Quoted 4 lines

Need get the new fence when we replace the old one.

Fixes 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")

Good catch, Reviewed-by: Christian König <[email protected]>

Going to push that in a minute.

Christian.

Quoted 17 lines
---
  drivers/dma-buf/dma-resv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-resv.c +1 -1
index 0cce6e4ec946..205acb2c744d 100644
@@ -343,7 +343,7 @@ void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
  		if (old->context != context)
  			continue;
 
-		dma_resv_list_set(list, i, replacement, usage);
+		dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
  		dma_fence_put(old);
  	}
  }
#2 lore raw

Did this ever land? I don't see it in drm-misc.

Alex

Quoted 31 lines · Christian König

Am 07.07.22 um 10:02 schrieb xinhui pan:

Quoted 4 lines

Need get the new fence when we replace the old one.

Fixes 047a1b877ed48 ("dma-buf & drm/amdgpu: remove dma_resv workaround")

Good catch, Reviewed-by: Christian König <[email protected]>

Going to push that in a minute.

Christian.

Quoted 17 lines
---
  drivers/dma-buf/dma-resv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-resv.c +1 -1
index 0cce6e4ec946..205acb2c744d 100644
@@ -343,7 +343,7 @@ void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
              if (old->context != context)
                      continue;
 
-             dma_resv_list_set(list, i, replacement, usage);
+             dma_resv_list_set(list, i, dma_fence_get(replacement), usage);
              dma_fence_put(old);
      }
  }