drm/amdkfd: fix SMI event cross-process information leak
Subsystems (3)
PATCH 1/1 drm/amdkfd: fix SMI event cross-process information leak
kfd_smi_ev_enabled() skips the suser privilege check when pid=0. PROCESS_START, PROCESS_END, and VMFAULT events are emitted with pid=0 while carrying another process's PID and command name, so any /dev/kfd user in the render group can monitor all GPU workloads.
Pass the target process PID into kfd_smi_event_add() for these events so the existing per-client filter restricts delivery to the owning process or CAP_SYS_ADMIN subscribers.
--- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +5 -3
@@ -254,8 +254,10 @@ void kfd_smi_event_update_vmfault(struct kfd_node *dev, uint16_t pasid)if (task_info) {/* Report VM faults from user applications, not retry from kernel */ if (task_info->task.pid) -kfd_smi_event_add (0 , dev,KFD_SMI_EVENT_VMFAULT ,KFD_EVENT_FMT_VMFAULT ( - task_info->task.pid, task_info->task.comm)); +kfd_smi_event_add (task_info->task.pid, dev, +KFD_SMI_EVENT_VMFAULT , +KFD_EVENT_FMT_VMFAULT (task_info->task.pid, + task_info->task.comm));amdgpu_vm_put_task_info (task_info); } }
@@ -356,7 +358,7 @@ void kfd_smi_event_process(struct kfd_process_device *pdd, bool start) task_info =amdgpu_vm_get_task_info_vm (avm);if (task_info) { - kfd_smi_event_add(0, pdd->dev, + kfd_smi_event_add(task_info->task.pid, pdd->dev, start ? KFD_SMI_EVENT_PROCESS_START : KFD_SMI_EVENT_PROCESS_END, KFD_EVENT_FMT_PROCESS(task_info->task.pid,
Signature · 1 line
2.43.0
Quoted 11 lines · Yongqiang Sun
kfd_smi_ev_enabled()skips the suser privilege check when pid=0.PROCESS_START,PROCESS_END, and VMFAULT events are emitted with pid=0 while carrying another process's PID and command name, so any/dev/kfduser in the render group can monitor all GPU workloads.Pass the target process PID into
kfd_smi_event_add()for these events so the existing per-client filter restricts delivery to the owning process orCAP_SYS_ADMINsubscribers.Signed-off-by Yongqiang Sun <[email protected]>
Quoted 33 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +5
-4@@ -254,8 +254,10 @@ void kfd_smi_event_update_vmfault(struct kfd_node *dev, uint16_t pasid)if (task_info) {/* Report VM faults from user applications, not retry from kernel */ if (task_info->task.pid) -kfd_smi_event_add (0 , dev,KFD_SMI_EVENT_VMFAULT ,KFD_EVENT_FMT_VMFAULT ( - task_info->task.pid, task_info->task.comm)); +kfd_smi_event_add (task_info->task.pid, dev, +KFD_SMI_EVENT_VMFAULT , +KFD_EVENT_FMT_VMFAULT (task_info->task.pid, + task_info->task.comm));amdgpu_vm_put_task_info (task_info); } }@@ -356,7 +358,7 @@ void kfd_smi_event_process(struct kfd_process_device *pdd, bool start) task_info =amdgpu_vm_get_task_info_vm (avm);if (task_info) { - kfd_smi_event_add(0, pdd->dev, + kfd_smi_event_add(task_info->task.pid, pdd->dev, start ? KFD_SMI_EVENT_PROCESS_START : KFD_SMI_EVENT_PROCESS_END, KFD_EVENT_FMT_PROCESS(task_info->task.pid, --2.43.0