Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] drm/amdkfd: use-after-free in kfd_process_destroy_pdds() [1] --
commit 27e966c319a74439c4a48d13a51742cea89473d5 Author: Jesse Zhang <[email protected]> drm/amdkfd: return the memory violation data to the debugger This commit records the size of GPU VM fault exception data in kfd_dbg_ev_raise() and frees vm_fault_exc_data when destroying the process device. > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c > b/drivers/gpu/drm/amd/amdkfd/kfd_process.c > index 546721b4d59ac..16131fdc55468 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c > @@ -1253,6 +1253,7 @@ static void kfd_process_destroy_pdds(struct kfd_process > *p) > atomic_dec(&pdd->dev->kfd->kfd_processes_count); > mutex_destroy(&pdd->doorbell_mutex); > > + kfree(pdd->vm_fault_exc_data); > kfree(pdd); > p->pdds[i] = NULL; > } [Severity: Critical] This problem wasn't introduced by this patch, but can kfd_process_destroy_pdds() dereference freed pdd->dev and pdd->dev->kfd memory [1] during device teardown? When a KFD process exits, it is removed from kfd_processes_table before its release work runs on kfd_process_wq. If kgd2kfd_teardown_processes() runs after the last process is removed from kfd_processes_table, it returns early and skips waiting for kfd_processes_count to reach zero: drivers/gpu/drm/amd/amdkfd/kfd_device.c:kgd2kfd_teardown_processes() { ... mutex_lock(&kfd_processes_mutex); if (hash_empty(kfd_processes_table)) { mutex_unlock(&kfd_processes_mutex); return; } ... mutex_unlock(&kfd_processes_mutex); /* wait all kfd processes use adev terminate */ while (!!atomic_read(&adev->kfd.dev->kfd_processes_count)) cond_resched(); } CPU0 CPU1 (kworker) kgd2kfd_teardown_processes() if (hash_empty(kfd_processes_table)) return; <device teardown frees kfd_node/kfd_dev> kfd_process_wq_release() kfd_process_destroy_pdds() atomic_dec(&pdd->dev->kfd->...); <-- use-after-free [1] https://sashiko.dev/#/bug/linux-89a2e0c3-8eea-4d17-956c-8aac02272705 -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
