From aff13198297c45d40810dd9e69d2a94f9a32541a Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Mon, 6 May 2019 13:23:05 -0400 Subject: [PATCH 2774/2940] drm/amdkfd: Allow the debugger functions on the current process Only check that the ioctl caller is an attached debugger if it is not targeting the current process. Change-Id: I8b6605620ecaec9f3b42abe937575becc4009bc6 Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 1822074c53eb..4abf4f462fa1 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -2565,7 +2565,6 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep, uint32_t data2; uint32_t data3; bool is_suspend_or_resume; - bool is_debbugger_attached = false; uint8_t id; debug_trap_action = args->op; @@ -2601,16 +2600,19 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep, goto out; } + if (target != p) { + bool is_debugger_attached = false; - rcu_read_lock(); - if (ptrace_parent(target->lead_thread) == current) - is_debbugger_attached = true; - rcu_read_unlock(); + rcu_read_lock(); + if (ptrace_parent(target->lead_thread) == current) + is_debugger_attached = true; + rcu_read_unlock(); - if (!is_debbugger_attached) { - pr_err("Cannot debug process\n"); - r = -ESRCH; - goto out; + if (!is_debugger_attached) { + pr_err("Cannot debug process\n"); + r = -ESRCH; + goto out; + } } mutex_lock(&target->mutex); -- 2.17.1