From: sashiko-bot@kernel.org
To: "Ruoyu Wang" <ruoyuw560@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe: keep process name fallback for diagnostics
Date: Tue, 09 Jun 2026 16:27:42 +0000 [thread overview]
Message-ID: <20260609162743.48D661F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260609162057.5-1-ruoyuw560@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless access to `task->comm` via `kstrdup()` creates a TOCTOU race leading to a non-null-terminated string and an out-of-bounds read.
--
commit f329e0d91af948bfcb07b90ac00f44ede0a2f8fc
Author: Ruoyu Wang <ruoyuw560@gmail.com>
drm/xe: keep process name fallback for diagnostics
This commit addresses an issue where diagnostic paths would use a NULL
pointer for a process name if allocation failed during file open. It keeps
the "no process" fallback unless the process name was successfully
allocated.
[ ... ]
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 4b247a3019d2d..697faf0f1048b 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -1590,7 +1590,8 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)
> }
>
> if (q->vm && q->vm->xef) {
> - process_name = q->vm->xef->process_name;
> + if (q->vm->xef->process_name)
> + process_name = q->vm->xef->process_name;
> pid = q->vm->xef->pid;
> }
[Severity: High]
This is a pre-existing issue, but does using this string in formatting
functions risk an out-of-bounds memory read?
Looking at xe_file_open() in drivers/gpu/drm/xe/xe_device.c, task->comm is
directly passed to kstrdup() without holding task_lock(task):
xef->process_name = kstrdup(task->comm, GFP_KERNEL);
Since task->comm can be modified concurrently by userspace via
prctl(PR_SET_NAME), kstrdup() can compute a short length during its internal
strlen() call, but copy characters from a longer replacement string during
memcpy(). This results in a heap buffer missing a null terminator.
When process_name is subsequently passed to xe_gt_notice() further down in
this function and printed via the %s format specifier:
xe_gt_notice(guc_to_gt(guc),
"Timedout job: seqno=%u, lrc_seqno=%u, guc_id=%d, flags=0x%lx in %s [%d]",
xe_sched_job_seqno(job), xe_sched_job_lrc_seqno(job),
q->guc->id, q->flags, process_name, pid);
Can this trigger an out-of-bounds read of adjacent slab memory, potentially
leading to KASAN panics or kernel memory disclosure?
Could the string copying in xe_file_open() be safely changed to use
get_task_comm() instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609162057.5-1-ruoyuw560@gmail.com?part=1
prev parent reply other threads:[~2026-06-09 16:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 16:20 [PATCH] drm/xe: keep process name fallback for diagnostics Ruoyu Wang
2026-06-09 16:27 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609162743.48D661F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ruoyuw560@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox