Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:

Pre-existing issues:
- [High] Unbounded string read from firmware data in `ivpu_fw_parse`.
--

commit 7d0d9c625b89d41a9d3cbe859e6e2b33348102cf
Author: Dawid Osuchowski <[email protected]>

accel/ivpu: Limit firmware log name prints to field size
    
This patch fixes an issue where the NPU firmware log name field is printed
using an unbounded string conversion. By enforcing a precision limit based
on the field's size, it prevents out-of-bounds memory reads if the firmware
string is missing its NUL terminator.

Closes: 
https://sashiko.dev/#/patchset/[email protected]?part=2

> diff --git a/drivers/accel/ivpu/ivpu_fw_log.c 
> b/drivers/accel/ivpu/ivpu_fw_log.c
> index 4f9055aa9d33f..9eafc42120b6a 100644
> --- a/drivers/accel/ivpu/ivpu_fw_log.c
> +++ b/drivers/accel/ivpu/ivpu_fw_log.c
> @@ -69,9 +69,9 @@ static int fw_log_from_bo(struct ivpu_device *vdev, struct 
> ivpu_bo *bo, u32 *off
>       *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, size, log->wrap_count, 
> log->header_version,
> -              header_size, log->format, log->alignment);
> +              "FW log name \"%.*s\", write offset 0x%x size 0x%x, wrap count 
> %d, hdr version %d size %d format %d, alignment %d",
> +              (int)ARRAY_SIZE(log->name), 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 patch fixes an
unbounded string read, is there a similar issue in ivpu_fw_parse() when
reading the firmware version?

Looking at drivers/accel/ivpu/ivpu_fw.c:ivpu_fw_parse():

        if (!scnprintf(fw->version, sizeof(fw->version), "%s", fw->file->data + 
VPU_FW_HEADER_SIZE))
                ivpu_warn(vdev, "Missing firmware version\n");

The scnprintf() function evaluates the length of the source string until a NUL
byte is found when no precision is provided for "%s", regardless of the
destination buffer size.

If the loaded firmware file lacks a NUL terminator at VPU_FW_HEADER_SIZE,
could this lead to an out-of-bounds read past the loaded firmware data?

This could trigger a page fault and expose adjacent kernel memory if a
malformed firmware file is supplied.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to