From: sashiko-bot@kernel.org
To: "Daniele Ceraolo Spurio" <daniele.ceraolospurio@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe: Add GuC FW path configfs overrides
Date: Thu, 19 Nov 2026 02:00:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-222315@kernel.org> (raw)
In-Reply-To: <20261119014602.243548-2-daniele.ceraolospurio@intel.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/xe/configfs: 1-byte OOB write in __gt_guc_override_show()
- [Medium] drm/xe/configfs: empty override in __gt_guc_override_store()
disables GuC
- [Medium] drm/xe: unchecked drmm_kstrdup() failure in
xe_configfs_guc_override()
- [Low] drm/xe/configfs: missing guc_overrides in
dump_custom_dev_config()
--
commit f425c98fc376b284cd705ef5abb819f7ae2fc52d
Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
drm/xe: Add GuC FW path configfs overrides
This commit adds per-GT configfs attributes (primary_gt_guc_override and
media_gt_guc_override) to override the GuC firmware path independently for
the primary and media GTs.
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 2ddd707a6dbd3..b6b544c3bc9da 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
[ ... ]
> @@ -309,6 +329,11 @@ struct xe_config_group_device {
> unsigned int max_vfs;
> bool admin_only_pf;
> } sriov;
> +
> + struct {
> + char *primary_gt;
> + char *media_gt;
> + } guc_overrides;
> } config;
>
> /* protects attributes */
> @@ -331,6 +356,10 @@ static const struct xe_config_device device_defaults = {
> .max_vfs = XE_DEFAULT_MAX_VFS,
> .admin_only_pf = XE_DEFAULT_ADMIN_ONLY_PF,
> },
> + .guc_overrides = {
> + .primary_gt = NULL,
> + .media_gt = NULL,
> + },
> };
[Severity: Low]
Should dump_custom_dev_config() also print guc_overrides.primary_gt and
guc_overrides.media_gt? When either override is set, memcmp() in
xe_configfs_check_device() logs "Found custom settings in configfs" and
calls dump_custom_dev_config(), which does not include the new fields.
> @@ -937,6 +966,84 @@ static ssize_t ctx_restore_post_bb_store(struct config_item *item,
> return wa_bb_store(dev->config.ctx_restore_post_bb, dev, data, sz);
> }
>
> +static ssize_t __gt_guc_override_show(struct xe_config_group_device *dev,
> + char **override, char *page)
> +{
> + guard(mutex)(&dev->lock);
> +
> + return sprintf(page, "%s\n", *override ? *override : "no override");
> +}
> +
> +static ssize_t __gt_guc_override_store(struct xe_config_group_device *dev,
> + char **override, const char *page, size_t len)
> +{
> + char *path;
> +
> + if (len > PATH_MAX)
> + return -EINVAL;
[Severity: High]
Can __gt_guc_override_show() write 1 byte past the end of the PAGE_SIZE
configfs read buffer?
In fs/configfs/file.c, fill_write_buffer() caps writes at
SIMPLE_ATTR_SIZE - 1 (4095) bytes, so len > PATH_MAX (4096) in
__gt_guc_override_store() accepts a 4095-byte string without a trailing
newline and stores a 4095-character string in *override. When the
attribute is read back, fill_read_buffer() passes a PAGE_SIZE (4096-byte)
buffer to __gt_guc_override_show(), and sprintf(page, "%s\n", *override)
writes 4095 characters, '\n', and '\0' (4097 bytes). Using sysfs_emit()
in __gt_guc_override_show() and rejecting len >= PATH_MAX in
__gt_guc_override_store() would avoid this overflow.
> +
> + guard(mutex)(&dev->lock);
> + if (is_bound(dev))
> + return -EBUSY;
> +
> + /*
> + * An empty string disables the override. Some bash commands can add a
> + * '\n' or '\0 ' at the end of the string, so consider a string of
> + * length 1 containing one of those characters as empty.
> + */
> + if (!len || (len == 1 && (page[0] == '\n' || page[0] == '\0'))) {
> + kfree(*override);
> + *override = NULL;
> + } else {
> + path = krealloc(*override, len + 1, GFP_KERNEL);
> + if (!path)
> + return -ENOMEM;
> +
> + memcpy(path, page, len);
> +
> + /*
> + * the echo command adds a trailing newline unless the -n option
> + * is used, so replace it if present.
> + */
> + if (path[len - 1] == '\n')
> + path[len - 1] = '\0';
> + else
> + path[len] = '\0';
> +
> + *override = path;
> + }
[Severity: Medium]
Can writing a NUL byte followed by a newline (e.g. "echo -e '\0'", where
len == 2 and page[0] == '\0') store a non-NULL empty string in *override?
Because the empty-string check requires len == 1, a 2-byte "\0\n" input
takes the else branch and stores a buffer starting with '\0'. During
probe, xe_configfs_guc_override() duplicates that empty string and
uc_fw_override() sets uc_fw->path to "", which causes uc_fw_request() to
mark GuC firmware as XE_UC_FIRMWARE_DISABLED and xe_wopcm_init() to fail
probe with -EINVAL. Checking page[0] == '\0' regardless of len (or
checking !strlen(path)) would treat any NUL-leading write as empty.
[ ... ]
> @@ -1479,6 +1592,43 @@ u32 xe_configfs_get_ctx_restore_post_bb(struct pci_dev *pdev,
> return len;
> }
>
> +/**
> + * xe_configfs_guc_override - get configfs guc override path
> + * @pdev: pci device
> + * @gt_type: type of the GT for which to get the guc override path
> + *
> + * Return: A new drmm-managed allocation containing the path to the specified GT
> + * guc override if set, NULL otherwise
> + */
> +const char *xe_configfs_guc_override(struct pci_dev *pdev, enum xe_gt_type gt_type)
> +{
> + struct xe_config_group_device *dev = find_xe_config_group_device(pdev);
> + struct drm_device *drm = pci_get_drvdata(pdev);
> + const char *override, *path = NULL;
> +
> + if (!dev)
> + return NULL;
> +
> + if (!drm)
> + goto out_put;
> +
> + scoped_guard(mutex, &dev->lock) {
> + if (gt_type == XE_GT_TYPE_MAIN)
> + override = dev->config.guc_overrides.primary_gt;
> + else if (gt_type == XE_GT_TYPE_MEDIA)
> + override = dev->config.guc_overrides.media_gt;
> + else
> + override = NULL;
> +
> + if (override)
> + path = drmm_kstrdup(drm, override, GFP_KERNEL);
> + }
> +
> +out_put:
> + config_group_put(&dev->group);
> + return path;
> +}
[Severity: Medium]
If drmm_kstrdup() fails, does xe_configfs_guc_override() return NULL and
make the allocation failure indistinguishable from having no override
configured? uc_fw_override() will then leave uc_fw->path set to the
default auto-selected firmware path and silently load the default firmware
instead of failing probe with -ENOMEM.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119014602.243548-2-daniele.ceraolospurio@intel.com?part=1
next prev parent reply other threads:[~2026-11-19 2:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 1:46 [PATCH] drm/xe: Add GuC FW path configfs overrides Daniele Ceraolo Spurio
2026-11-19 2:00 ` sashiko-bot [this message]
2026-11-19 6:49 ` ✓ CI.KUnit: success for " Patchwork
2026-11-19 7:25 ` ✓ Xe.CI.BAT: " 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=sashiko-outbox-222315@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=daniele.ceraolospurio@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