Patch "drm/amdgpu: fix use-after-free during gpu recovery" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/amdgpu: fix use-after-free during gpu recovery

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-amdgpu-fix-use-after-free-during-gpu-recovery.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ece2880603406e6fbd2531ad6a823db6517e2d08
Author: Stanley.Yang <Stanley.Yang@xxxxxxx>
Date:   Wed Nov 16 17:08:22 2022 +0800

    drm/amdgpu: fix use-after-free during gpu recovery
    
    [ Upstream commit 3cb93f390453cde4d6afda1587aaa00e75e09617 ]
    
    [Why]
        [  754.862560] refcount_t: underflow; use-after-free.
        [  754.862898] Call Trace:
        [  754.862903]  <TASK>
        [  754.862913]  amdgpu_job_free_cb+0xc2/0xe1 [amdgpu]
        [  754.863543]  drm_sched_main.cold+0x34/0x39 [amd_sched]
    
    [How]
        The fw_fence may be not init, check whether dma_fence_init
        is performed before job free
    
    Signed-off-by: Stanley.Yang <Stanley.Yang@xxxxxxx>
    Reviewed-by: Tao Zhou <tao.zhou1@xxxxxxx>
    Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 3b025aace283..eb4c0523e42d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -167,7 +167,11 @@ static void amdgpu_job_free_cb(struct drm_sched_job *s_job)
 	amdgpu_sync_free(&job->sync);
 	amdgpu_sync_free(&job->sched_sync);
 
-	dma_fence_put(&job->hw_fence);
+	/* only put the hw fence if has embedded fence */
+	if (!job->hw_fence.ops)
+		kfree(job);
+	else
+		dma_fence_put(&job->hw_fence);
 }
 
 void amdgpu_job_free(struct amdgpu_job *job)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux