Skip to contentSkip to conversation

drm/amdkfd: Fix missing authorization check in KFD_IOC_DBG_TRAP_DISABLE

PATCH In review Gang Ba 2 participants 2 messages Jul 20

Subsystems (3)
lore
Share & tools
lore

Gang Ba

author
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix missing authorization check in KFD_IOC_DBG_TRAP_DISABLE

Prevent unauthorized termination of active GPU debug sessions. Previously, users with /dev/kfd access could terminate another process's debug session without proper ownership or ptrace authorization.

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +7 -3
index 7d058d93e219..05dd0b6a87f0 100644
@@ -3112,10 +3112,14 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
 		goto out;
 	}
 
-	/* Check if target is still PTRACED. */
+	/*
+	 * Verify debugger has permission to debug target process.
+	 * For cross-process debugging, require active ptrace relationship.
+	 * This applies to ALL operations to prevent unauthorized interference.
+	 */
 	rcu_read_lock();
-	if (target != p && args->op != KFD_IOC_DBG_TRAP_DISABLE
-				&& ptrace_parent(target->lead_thread) != current) {
+	if (target != p && ptrace_parent(target->lead_thread) != current
+	                && target->debugger_process != p) {
 		pr_err("PID %i is not PTRACED and cannot be debugged\n", args->pid);
 		r = -EPERM;
 	}
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw

AMD General

Quoted 45 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Gang Ba
Sent: July 20, 2026 11:31 AM
To: [email protected]
Cc: [email protected]
Subject: [PATCH] drm/amdkfd: Fix missing authorization check in KFD_IOC_DBG_TRAP_DISABLE

Prevent unauthorized termination of active GPU debug sessions. Previously, users with /dev/kfd access could terminate another process's debug session without proper ownership or ptrace authorization.

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index 7d058d93e219..05dd0b6a87f0 100644
@@ -3112,10 +3112,14 @@ static int kfd_ioctl_set_debug_trap(struct file *filep,

struct kfd_process *p, v

              goto out;
      }
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +5 -3
-     /* Check if target is still PTRACED. */
+     /*
+      * Verify debugger has permission to debug target process.
+      * For cross-process debugging, require active ptrace relationship.
+      * This applies to ALL operations to prevent unauthorized interference.
+      */
      rcu_read_lock();
-     if (target != p && args->op != KFD_IOC_DBG_TRAP_DISABLE
-                             && ptrace_parent(target->lead_thread) !=

current) {

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+     if (target != p && ptrace_parent(target->lead_thread) != current
+                     && target->debugger_process != p) {
              pr_err("PID %i is not PTRACED and cannot be debugged\n", args-
Quoted 1 line

pid);

              r = -EPERM;
      }

--
2.54.0