From: sashiko-bot@kernel.org
To: "Raag Jadav" <raag.jadav@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v10 01/10] drm/xe/uc_fw: Allow re-initializing firmware
Date: Fri, 21 Aug 2026 11:41:39 +0000 [thread overview]
Message-ID: <20260821114140.67AF61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821112436.545405-2-raag.jadav@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] xe_uc_fw_reinit() lacks an IS_SRIOV_VF() check, causing VF firmware state corruption and potential NULL pointer dereference.
Pre-existing issues:
- [High] Integer overflow in parse_gsc_layout() leads to out-of-bounds read and potential kernel panic.
--
--- Patch [1]: [PATCH v10 01/10] drm/xe/uc_fw: Allow re-initializing firmware ---
commit 0789aa0c08f22f9ec32c3de1bbde4b80f0984ba2
Author: Raag Jadav <raag.jadav@intel.com>
drm/xe/uc_fw: Allow re-initializing firmware
This commit introduces xe_uc_fw_reinit() to support re-initializing
firmware without reloading the driver. It copies the firmware back
to its buffer object and marks it as loadable after events like
PCIe FLR.
> diff --git a/drivers/gpu/drm/xe/xe_uc_fw.c b/drivers/gpu/drm/xe/xe_uc_fw.c
> --- a/drivers/gpu/drm/xe/xe_uc_fw.c
> +++ b/drivers/gpu/drm/xe/xe_uc_fw.c
[ ... ]
> +/**
> + * xe_uc_fw_reinit() - Re-initialize uC firmware into its bo
> + * @uc_fw: uC firmware
> + *
> + * Returns: 0 on success, negative error code otherwise.
> + */
> +int xe_uc_fw_reinit(struct xe_uc_fw *uc_fw)
> +{
> + struct xe_device *xe = uc_fw_to_xe(uc_fw);
> + struct xe_uc_fw_version old_fw, new_fw;
> + const struct firmware *fw = NULL;
> + int err;
> +
> + /* Make sure the status was cleared the last time we reset the uc */
> + xe_assert(xe, !xe_uc_fw_is_loaded(uc_fw));
> +
> + /* We shouldn't be here for the firmware which wasn't available */
> + if (!xe_uc_fw_is_available(uc_fw))
> + return -ENOEXEC;
[Severity: High]
Does this code safely handle SR-IOV Virtual Functions (VFs)?
On VFs, firmware loading is handled by the PF, so the VF initializes its
firmware state with the dummy path "Loaded by PF" and skips allocating
uc_fw->bo. Since the VF reaches the XE_UC_FIRMWARE_PRELOADED status, the
xe_uc_fw_is_available() check above will pass.
Because there is no IS_SRIOV_VF() check here, this proceeds to request
the dummy firmware path. If that request fails, the VF's status is
incorrectly overwritten to XE_UC_FIRMWARE_INIT_FAIL.
If a file named "Loaded by PF" actually exists, the code proceeds to call
uc_fw_reinit():
drivers/gpu/drm/xe/xe_uc_fw.c:uc_fw_reinit() {
...
xe_map_memcpy_to(xe, &uc_fw->bo->vmap, 0, data, uc_fw->size);
...
}
Since uc_fw->bo is NULL on VFs, will this lead to a NULL pointer
dereference?
> +
> + old_fw = uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
> +
> + err = firmware_request_nowarn(&fw, uc_fw->path, xe->drm.dev);
> + if (err)
> + goto init_fail;
> +
> + err = parse_headers(uc_fw, fw);
[Severity: High]
This isn't a bug introduced by this patch, but could the firmware parsing
called here be vulnerable to an integer overflow?
Inside parse_headers(), when handling GSC firmware, it calls
parse_gsc_layout() which performs the following bounds check:
drivers/gpu/drm/xe/xe_uc_fw.c:parse_gsc_layout() {
...
min_size = layout->boot1.offset + layout->boot1.size;
if (size < min_size) {
...
return -ENODATA;
}
...
bpdt_header = data + layout->boot1.offset;
if (bpdt_header->signature != GSC_BPDT_HEADER_SIGNATURE) {
...
}
Since both layout->boot1.offset and layout->boot1.size are 32-bit
unsigned integers, can a crafted firmware cause their sum to wrap around?
If they wrap before being assigned to the 64-bit min_size, the bounds
check would be bypassed, potentially resulting in an out-of-bounds read
when dereferencing bpdt_header->signature.
> + if (err)
> + goto restore_old;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821112436.545405-1-raag.jadav@intel.com?part=1
next prev parent reply other threads:[~2026-08-21 11:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 11:23 [PATCH v10 00/10] Introduce Xe PCIe FLR Raag Jadav
2026-08-21 11:23 ` [PATCH v10 01/10] drm/xe/uc_fw: Allow re-initializing firmware Raag Jadav
2026-08-21 11:41 ` sashiko-bot [this message]
2026-08-21 11:23 ` [PATCH v10 02/10] drm/xe/guc_submit: Introduce guc_exec_queue_reinit_kernel() Raag Jadav
2026-08-21 11:52 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 03/10] drm/xe/gt: Introduce FLR helpers Raag Jadav
2026-08-21 11:23 ` [PATCH v10 04/10] drm/xe/bo_evict: Introduce xe_bo_restore_map() Raag Jadav
2026-08-21 11:23 ` [PATCH v10 05/10] drm/xe/exec_queue: Introduce xe_exec_queue_reinit() Raag Jadav
2026-08-21 11:43 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 06/10] drm/xe/migrate: Introduce xe_migrate_reinit() Raag Jadav
2026-08-21 11:39 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 07/10] drm/xe/pm: Introduce xe_device_suspend/resume() Raag Jadav
2026-08-21 11:43 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 08/10] drm/xe: Introduce temporary device wedging Raag Jadav
2026-08-21 11:37 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 09/10] drm/xe/pci: Introduce PCIe Function Level Reset Raag Jadav
2026-08-21 11:39 ` sashiko-bot
2026-08-21 11:23 ` [PATCH v10 10/10] drm/xe/doc: Wire up PCI Error Handling Raag Jadav
2026-08-21 11:31 ` ✗ CI.checkpatch: warning for Introduce Xe PCIe FLR (rev10) Patchwork
2026-08-21 11:33 ` ✓ CI.KUnit: success " Patchwork
2026-08-21 12:37 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-21 14:38 ` ✓ 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=20260821114140.67AF61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=raag.jadav@intel.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