lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251125-change_pid_t_to_ppid-v1-1-6ddd817a953e@intel.com>
Date: Tue, 25 Nov 2025 11:56:14 +0100
From: Andrzej Hajda <andrzej.hajda@...el.com>
To: intel-xe@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org, 
 Lucas De Marchi <lucas.demarchi@...el.com>, 
 Thomas Hellström <thomas.hellstrom@...ux.intel.com>, 
 Rodrigo Vivi <rodrigo.vivi@...el.com>, 
 Andrzej Hajda <andrzej.hajda@...el.com>
Subject: [PATCH] drm/xe/xe_file: change pid type from pid_t to pid pointer

Some xe structures can outlive xef->drm pointer, but they need to
access associated process info. struct pid is refcounted (in contrast to
drm_file), so it's life can be safely prolonged till end of xe_file life.

The patch is necessary for incoming eudebug feature.

Signed-off-by: Andrzej Hajda <andrzej.hajda@...el.com>
---
 drivers/gpu/drm/xe/xe_devcoredump.c  | 2 +-
 drivers/gpu/drm/xe/xe_device.c       | 5 +++--
 drivers/gpu/drm/xe/xe_device_types.h | 6 +++---
 drivers/gpu/drm/xe/xe_guc_submit.c   | 2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index bf347714b5e090a408301d778d9c75af559ebaf6..2caddad2b09cc7907025eb1f6d2f2925060d8cf1 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -335,7 +335,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
 
 	if (q->vm && q->vm->xef) {
 		process_name = q->vm->xef->process_name;
-		ss->pid = q->vm->xef->pid;
+		ss->pid = pid_nr(q->vm->xef->pid);
 	}
 
 	strscpy(ss->process_name, process_name);
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 1197f914ef777ab9d466853e5893adc744d59210..b11b7bb70d9afea4b3d108ed5e505c81755d41bd 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -108,10 +108,10 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
 	file->driver_priv = xef;
 	kref_init(&xef->refcount);
 
-	task = get_pid_task(rcu_access_pointer(file->pid), PIDTYPE_PID);
+	xef->pid = get_pid(rcu_access_pointer(file->pid));
+	task = get_pid_task(xef->pid, PIDTYPE_PID);
 	if (task) {
 		xef->process_name = kstrdup(task->comm, GFP_KERNEL);
-		xef->pid = task->pid;
 		put_task_struct(task);
 	}
 
@@ -126,6 +126,7 @@ static void xe_file_destroy(struct kref *ref)
 	mutex_destroy(&xef->exec_queue.lock);
 	xa_destroy(&xef->vm.xa);
 	mutex_destroy(&xef->vm.lock);
+	put_pid(xef->pid);
 
 	xe_drm_client_put(xef->client);
 	kfree(xef->process_name);
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 6ce3247d1bd8eff33ebc7b55338df013f26108e7..a8bfcf7b1fcc39f5c3419d51ee1c09df390e4f2d 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -706,10 +706,10 @@ struct xe_file {
 	char *process_name;
 
 	/**
-	 * @pid: pid for file handle, used to safely output uring error
-	 * situations where xe file can outlive process
+	 * @pid: pid for file handle, used to safely access process info
+	 * in situations where xe file can outlive drm_file
 	 */
-	pid_t pid;
+	struct pid *pid;
 
 	/** @refcount: ref count of this xe file */
 	struct kref refcount;
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 7e0882074a992c7022a2e3901a4218a6041b38d6..6cc1b830a318f9c2fc8c5040a310e92b6602c226 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -1350,7 +1350,7 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)
 
 	if (q->vm && q->vm->xef) {
 		process_name = q->vm->xef->process_name;
-		pid = q->vm->xef->pid;
+		pid = pid_nr(q->vm->xef->pid);
 	}
 
 	if (!exec_queue_killed(q))

---
base-commit: c9ffb8a8ab1294c1870e017e0502cb8089d3d8b8
change-id: 20251125-change_pid_t_to_ppid-1373f1e68d99

Best regards,
-- 
Andrzej Hajda <andrzej.hajda@...el.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ