From: sashiko-bot@kernel.org
To: "Dawid Osuchowski" <dawid.osuchowski@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] accel/ivpu: Validate firmware log buffer metadata
Date: Thu, 27 Aug 2026 10:38:14 +0000 [thread overview]
Message-ID: <20260827103814.DB7341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827102339.281799-3-dawid.osuchowski@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unsafe printing of firmware-controlled string without length bounds could lead to out-of-bounds read.
--
commit fd0e38bea76a0e3e0f409139f3cf70f7ae5a79ea
Author: Magdalena Schulfer <magdalena.schulfer@intel.com>
accel/ivpu: Validate firmware log buffer metadata
The tracing log headers parsed by fw_log_print_buffer() reside in
DMA-shared BOs that the NPU firmware can write to. This commit mitigates
a TOCTOU vulnerability by snapshotting the header size and size fields
before validating them.
> diff --git a/drivers/accel/ivpu/ivpu_fw_log.c b/drivers/accel/ivpu/ivpu_fw_log.c
> index 716467aa31567..4f9055aa9d33f 100644
> --- a/drivers/accel/ivpu/ivpu_fw_log.c
> +++ b/drivers/accel/ivpu/ivpu_fw_log.c
[ ... ]
> @@ -39,26 +46,32 @@ static int fw_log_from_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, u32 *off
[ ... ]
> - *out_log = log;
> - *offset += log->size;
> + desc->log = log;
> + desc->header_size = header_size;
> + desc->size = size;
> + *offset += size;
>
> ivpu_dbg(vdev, FW_BOOT,
> "FW log name \"%s\", write offset 0x%x size 0x%x, wrap count %d, hdr version %d size %d format %d, alignment %d",
> - log->name, log->write_index, log->size, log->wrap_count, log->header_version,
> - log->header_size, log->format, log->alignment);
> + log->name, log->write_index, size, log->wrap_count, log->header_version,
> + header_size, log->format, log->alignment);
[Severity: High]
This isn't a bug introduced by this patch, but since this commit aims to
secure the untrusted log header, is it safe to print log->name using %s?
The name array (16 bytes) in struct vpu_tracing_buffer_header is controlled by
the firmware. If the firmware fails to null-terminate it, printing it with %s
in ivpu_dbg() will cause an out-of-bounds read. This could leak adjacent
memory into the kernel log or trigger a panic if the read crosses into
an unmapped page.
Could we bound the length by using %.16s instead?
A similar issue also exists in fw_log_print_buffer(), where log->name is
repeatedly passed to drm_printf() using %s without length limits.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827102339.281799-1-dawid.osuchowski@linux.intel.com?part=2
prev parent reply other threads:[~2026-08-27 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 10:23 [PATCH 0/2] accel/ivpu: Harden parsing of firmware-shared buffers Dawid Osuchowski
2026-08-27 10:23 ` [PATCH 1/2] accel/ivpu: Validate full buffer range in ivpu_to_cpu_addr Dawid Osuchowski
2026-08-27 10:23 ` [PATCH 2/2] accel/ivpu: Validate firmware log buffer metadata Dawid Osuchowski
2026-08-27 10:38 ` 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=20260827103814.DB7341F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dawid.osuchowski@linux.intel.com \
--cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.