From: sashiko-bot@kernel.org
To: "Anoop, Vijay" <anoop.c.vijay@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 4/4] drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry
Date: Thu, 03 Sep 2026 14:12:38 +0000 [thread overview]
Message-ID: <20260903141239.4A1001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903140340.83500-10-anoop.c.vijay@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unprotected state modifications to the shared xe_sysctrl_debugfs_entry in the mailbox debugfs read/write paths.
- [Low] The mailbox debugfs write function fails to skip empty tokens when parsing the group and command IDs, causing valid user input with leading or consecutive whitespace to be rejected.
--
commit e5d10f0b8e0daddacee17c1115009e5b3144b469
Author: Anoop Vijay <anoop.c.vijay@intel.com>
drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry
Adds a generic mailbox debugfs entry that allows any System Controller
mailbox command to be issued for bring-up and debug.
> diff --git a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
> index 258479d605cbe..e5bc0a5dc31f8 100644
> --- a/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_sysctrl_debugfs.c
[ ... ]
> +static ssize_t xe_sysctrl_mailbox_write(struct file *file, const char __user *ubuf,
> + size_t len, loff_t *offp)
> +{
[ ... ]
> + tmp = kbuf;
> +
> + token = strsep(&tmp, " \t\n");
> + if (!token || kstrtoul(token, 0, &val) || val > 0xFF) {
[Severity: Low]
Does this code reject valid user input with leading spaces? When parsing the
group ID in xe_sysctrl_mailbox_write(), if a user executes a command like
"echo ' 1 2' > mailbox", strsep() will return an empty string for the leading
space. This causes kstrtoul() to fail and reject the command.
> + xe_err(xe, "sysctrl: invalid mailbox group id\n");
> + return -EINVAL;
> + }
> + group = (u8)val;
> +
> + token = strsep(&tmp, " \t\n");
> + if (!token || kstrtoul(token, 0, &val) || val > 0xFF) {
[Severity: Low]
The same parsing issue appears here for the command ID when there are
consecutive spaces. Can these be updated to skip empty tokens, similar to how
the payload byte parsing loop handles them?
> + xe_err(xe, "sysctrl: invalid mailbox command id\n");
> + return -EINVAL;
> + }
[ ... ]
> + entry->group = group;
> + entry->command = command;
> +
> + xe_sysctrl_create_command(&cmd, group, command, input_len ? input : NULL, input_len,
> + entry->response_buf, XE_SYSCTRL_MB_MAX_MESSAGE_SIZE);
> +
> + guard(xe_pm_runtime)(xe);
> + entry->status = xe_sysctrl_send_command(entry->sc, &cmd, &out_len);
> + entry->response_len = entry->status ? 0 : out_len;
[Severity: Medium]
Are these shared state modifications protected against concurrent access? If
two processes concurrently execute xe_sysctrl_mailbox_write() on the mailbox
debugfs file, could it cause a data race? This might corrupt the shared
xe_sysctrl_debugfs_entry state and mix command arguments or response data
from different threads.
> + return entry->status ? entry->status : len;
> +}
> +
> +static int xe_sysctrl_mailbox_show(struct seq_file *m, void *data)
> +{
> + struct xe_sysctrl_debugfs_entry *entry = m->private;
> + size_t i;
[ ... ]
> + if (entry->response_len) {
> + seq_puts(m, "Response data:\n");
> + for (i = 0; i < entry->response_len; i++) {
> + if (i && (i % 16) == 0)
> + seq_putc(m, '\n');
> + seq_printf(m, "%02x ", entry->response_buf[i]);
> + }
[Severity: Medium]
Similarly, this shared state is read locklessly in xe_sysctrl_mailbox_show().
Could a concurrent write operation interleave during this loop and cause
inconsistent or mixed-up data to be displayed in the debugfs output?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903140340.83500-6-anoop.c.vijay@intel.com?part=4
next prev parent reply other threads:[~2026-09-03 14:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 14:03 [PATCH v4 0/4] drm/xe/sysctrl: Add System Controller debugfs Anoop, Vijay
2026-09-03 14:03 ` [PATCH v4 1/4] drm/xe/sysctrl: Add System Controller get application status Anoop, Vijay
2026-09-03 14:16 ` sashiko-bot
2026-09-03 19:17 ` Umesh Nerlige Ramappa
2026-09-03 20:12 ` Anoop Vijay
2026-09-03 20:42 ` Ruhl, Michael J
2026-09-04 3:13 ` Anoop Vijay
2026-09-03 14:03 ` [PATCH v4 2/4] drm/xe/sysctrl: Add sysctrl debugfs infrastructure and loopback test interface Anoop, Vijay
2026-09-03 14:13 ` sashiko-bot
2026-09-03 14:03 ` [PATCH v4 3/4] drm/xe/sysctrl: Add RAS error injection debugfs interface Anoop, Vijay
2026-09-03 14:13 ` sashiko-bot
2026-09-03 14:03 ` [PATCH v4 4/4] drm/xe/sysctrl: Add generic mailbox passthrough debugfs entry Anoop, Vijay
2026-09-03 14:12 ` sashiko-bot [this message]
2026-09-03 14:10 ` ✗ CI.checkpatch: warning for drm/xe/sysctrl: Add System Controller debugfs (rev4) Patchwork
2026-09-03 14:12 ` ✓ CI.KUnit: success " Patchwork
2026-09-03 15:02 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-04 1:27 ` ✓ Xe.CI.FULL: " Patchwork
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=20260903141239.4A1001F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anoop.c.vijay@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--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