drm/amdgpu: fix use-after-free issue
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix use-after-free issue
Delete fence fallback timer to fix the ramdom
use-after-free issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -0
@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); }else { +del_timer_sync (&ring->fence_drv.fallback_timer);kfree (ring->fence_drv.fences); }
Signature · 1 line
2.41.0
Christian König
maintainerAm 22.04.24 um 10:47 schrieb Jack Xiao:
Quoted 2 lines
Delete fence fallback timer to fix the ramdom
use-after-free issue.
That's already done in amdgpu_fence_driver_hw_fini() and absolutely shouldn't be in amdgpu_ring_fini().
And the kfree(ring->fence_drv.fences); shouldn't be there either since that is done in amdgpu_fence_driver_sw_fini().
Regards,
Christian.
Quoted 18 lines
Signed-off-by Jack Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); }else { +del_timer_sync (&ring->fence_drv.fallback_timer);kfree (ring->fence_drv.fences); }
Quoted 10 lines · Christian König
Am 22.04.24 um 10:47 schrieb Jack Xiao:
Quoted 2 lines
Delete fence fallback timer to fix the ramdom
use-after-free issue.That's already done in
amdgpu_fence_driver_hw_fini()and absolutely shouldn't be inamdgpu_ring_fini().And the
kfree(ring->fence_drv.fences); shouldn't be there either since that is done inamdgpu_fence_driver_sw_fini().
In the present logic, these are part of special rings dynamically created for mes self tests with amdgpu_mes_add_ring/amdgpu_mes_remove_ring.
Thanks,
Lijo
Quoted 23 lines
Regards,
Christian.Quoted 19 lines
Signed-off-by Jack Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c| 1 +1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); } else { + del_timer_sync(&ring->fence_drv.fallback_timer); kfree(ring->fence_drv.fences); }
Christian König
maintainerAm 22.04.24 um 11:37 schrieb Lazar, Lijo:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 22.04.24 um 10:47 schrieb Jack Xiao:
Quoted 2 lines
Delete fence fallback timer to fix the ramdom
use-after-free issue.That's already done in
amdgpu_fence_driver_hw_fini()and absolutely shouldn't be inamdgpu_ring_fini().And the
kfree(ring->fence_drv.fences); shouldn't be there either since that is done inamdgpu_fence_driver_sw_fini().In the present logic, these are part of special rings dynamically created for mes self tests with amdgpu_mes_add_ring/amdgpu_mes_remove_ring.
Ok, we should probably stop doing that altogether.
Shashanks work of utilizing the MES in userspace is nearly finished and we don't really need the MES test in the kernel any more.
Regards,
Christian.
Quoted 25 lines
Thanks,
LijoQuoted 21 lines
Regards,
Christian.Quoted 18 lines
Signed-off-by Jack Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); } else { + del_timer_sync(&ring->fence_drv.fallback_timer); kfree(ring->fence_drv.fences); }
Quoted 12 lines · Christian König
Am 22.04.24 um 11:37 schrieb Lazar, Lijo:
Quoted 11 lines · Christian König
Quoted 9 lines
Am 22.04.24 um 10:47 schrieb Jack Xiao:
Quoted 2 lines
Delete fence fallback timer to fix the ramdom
use-after-free issue.That's already done in
amdgpu_fence_driver_hw_fini()and absolutely shouldn't be inamdgpu_ring_fini().And the
kfree(ring->fence_drv.fences); shouldn't be there either since that is done inamdgpu_fence_driver_sw_fini().
Quoted 9 lines
Quoted 3 lines
In the present logic, these are part of special rings dynamically created for mes self tests with amdgpu_mes_add_ring/amdgpu_mes_remove_ring.
Ok, we should probably stop doing that altogether.
Shashanks work of utilizing the MES in userspace is nearly finished and we don't really need the MES test in the kernel any more.
A v2 of the patch is posted. Can we use it temporarily till Shashank's work is in place? Assuming Shashank's work will also include removing MES self test in kernel.
Thanks,
Lijo
Quoted 29 lines
Regards,
Christian.Quoted 25 lines
Thanks,
LijoQuoted 21 lines
Regards,
Christian.Quoted 18 lines
Signed-off-by Jack Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c| 1 +1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); } else { + del_timer_sync(&ring->fence_drv.fallback_timer); kfree(ring->fence_drv.fences); }
Christian König
maintainerAm 22.04.24 um 13:29 schrieb Lazar, Lijo:
Quoted 15 lines · Christian König
Quoted 14 lines
Am 22.04.24 um 11:37 schrieb Lazar, Lijo:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 22.04.24 um 10:47 schrieb Jack Xiao:
Quoted 2 lines
Delete fence fallback timer to fix the ramdom
use-after-free issue.That's already done in
amdgpu_fence_driver_hw_fini()and absolutely shouldn't be inamdgpu_ring_fini().And the
kfree(ring->fence_drv.fences); shouldn't be there either since that is done inamdgpu_fence_driver_sw_fini().In the present logic, these are part of special rings dynamically created for mes self tests with amdgpu_mes_add_ring/amdgpu_mes_remove_ring.
Quoted 7 lines
Quoted 5 lines
Ok, we should probably stop doing that altogether.
Shashanks work of utilizing the MES in userspace is nearly finished and we don't really need the MES test in the kernel any more.
A v2 of the patch is posted. Can we use it temporarily till Shashank's work is in place?
Yes, absolutely.
Quoted 2 lines
Assuming Shashank's work will also include removing MES self test in kernel.
Yes, that was the long term plan. But no idea when we can completely upstream that work.
Regards,
Christian.
Quoted 31 lines
Thanks,
LijoQuoted 27 lines
Regards,
Christian.Quoted 24 lines
Thanks,
LijoQuoted 21 lines
Regards,
Christian.Quoted 18 lines
Signed-off-by Jack Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-0@@ -390,6 +390,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) &ring->gpu_addr, (void **)&ring->ring); } else { + del_timer_sync(&ring->fence_drv.fallback_timer); kfree(ring->fence_drv.fences); }