aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.19.8/2774-drm-amdkfd-Allow-the-debugger-functions-on-the-curre.patch
blob: f6a07e46e3ac0c337a8f642acd1c4ffa3c5b0ff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From aff13198297c45d40810dd9e69d2a94f9a32541a Mon Sep 17 00:00:00 2001
From: Felix Kuehling <Felix.Kuehling@amd.com>
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 <Felix.Kuehling@amd.com>
---
 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