All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] accel/ivpu: Add bounds checks for firmware log indices
@ 2026-05-29 11:58 Andrzej Kacprowski
  2026-05-29 12:06 ` Wachowski, Karol
  0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Kacprowski @ 2026-05-29 11:58 UTC (permalink / raw)
  To: dri-devel
  Cc: oded.gabbay, jeff.hugo, lizhi.hou, karol.wachowski,
	dawid.osuchowski, Andrzej Kacprowski, stable

Add validation that read and write indices in the firmware log buffer
are within valid bounds (< data_size) before using them. If
out-of-bounds indices are encountered (from firmware), clamp them to
safe values instead of proceeding with invalid offsets.

This prevents potential out-of-bounds buffer access when firmware
supplies invalid log indices.

Fixes: 1fc1251149a7 ("accel/ivpu: Refactor functions in ivpu_fw_log.c")
Cc: <stable@vger.kernel.org> # v6.18+
Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
---
 drivers/accel/ivpu/ivpu_fw_log.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/accel/ivpu/ivpu_fw_log.c b/drivers/accel/ivpu/ivpu_fw_log.c
index 337c906b0210..275baf844b56 100644
--- a/drivers/accel/ivpu/ivpu_fw_log.c
+++ b/drivers/accel/ivpu/ivpu_fw_log.c
@@ -98,6 +98,11 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha
 	u32 log_start = only_new_msgs ? READ_ONCE(log->read_index) : 0;
 	u32 log_end = READ_ONCE(log->write_index);
 
+	if (log_start >= data_size)
+		log_start = 0;
+	if (log_end > data_size)
+		log_end = data_size;
+
 	if (log->wrap_count == log->read_wrap_count) {
 		if (log_end <= log_start) {
 			drm_printf(p, "==== %s \"%s\" log empty ====\n", prefix, log->name);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] accel/ivpu: Add bounds checks for firmware log indices
  2026-05-29 11:58 [PATCH] accel/ivpu: Add bounds checks for firmware log indices Andrzej Kacprowski
@ 2026-05-29 12:06 ` Wachowski, Karol
  2026-06-02  5:49   ` Wachowski, Karol
  0 siblings, 1 reply; 3+ messages in thread
From: Wachowski, Karol @ 2026-05-29 12:06 UTC (permalink / raw)
  To: Andrzej Kacprowski, dri-devel
  Cc: oded.gabbay, jeff.hugo, lizhi.hou, dawid.osuchowski, stable

On 29-May-26 13:58, Andrzej Kacprowski wrote:
> Add validation that read and write indices in the firmware log buffer
> are within valid bounds (< data_size) before using them. If
> out-of-bounds indices are encountered (from firmware), clamp them to
> safe values instead of proceeding with invalid offsets.
> 
> This prevents potential out-of-bounds buffer access when firmware
> supplies invalid log indices.
> 
> Fixes: 1fc1251149a7 ("accel/ivpu: Refactor functions in ivpu_fw_log.c")
> Cc: <stable@vger.kernel.org> # v6.18+
> Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>

Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>

> ---
>   drivers/accel/ivpu/ivpu_fw_log.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/accel/ivpu/ivpu_fw_log.c b/drivers/accel/ivpu/ivpu_fw_log.c
> index 337c906b0210..275baf844b56 100644
> --- a/drivers/accel/ivpu/ivpu_fw_log.c
> +++ b/drivers/accel/ivpu/ivpu_fw_log.c
> @@ -98,6 +98,11 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha
>   	u32 log_start = only_new_msgs ? READ_ONCE(log->read_index) : 0;
>   	u32 log_end = READ_ONCE(log->write_index);
>   
> +	if (log_start >= data_size)
> +		log_start = 0;
> +	if (log_end > data_size)
> +		log_end = data_size;
> +
>   	if (log->wrap_count == log->read_wrap_count) {
>   		if (log_end <= log_start) {
>   			drm_printf(p, "==== %s \"%s\" log empty ====\n", prefix, log->name);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] accel/ivpu: Add bounds checks for firmware log indices
  2026-05-29 12:06 ` Wachowski, Karol
@ 2026-06-02  5:49   ` Wachowski, Karol
  0 siblings, 0 replies; 3+ messages in thread
From: Wachowski, Karol @ 2026-06-02  5:49 UTC (permalink / raw)
  To: Andrzej Kacprowski, dri-devel
  Cc: oded.gabbay, jeff.hugo, lizhi.hou, dawid.osuchowski, stable

On 29-May-26 14:06, Wachowski, Karol wrote:
> On 29-May-26 13:58, Andrzej Kacprowski wrote:
>> Add validation that read and write indices in the firmware log buffer
>> are within valid bounds (< data_size) before using them. If
>> out-of-bounds indices are encountered (from firmware), clamp them to
>> safe values instead of proceeding with invalid offsets.
>>
>> This prevents potential out-of-bounds buffer access when firmware
>> supplies invalid log indices.
>>
>> Fixes: 1fc1251149a7 ("accel/ivpu: Refactor functions in ivpu_fw_log.c")
>> Cc: <stable@vger.kernel.org> # v6.18+
>> Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
> 
> Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>
> 

Applied to drm-misc-fixes.

>> ---
>>   drivers/accel/ivpu/ivpu_fw_log.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/accel/ivpu/ivpu_fw_log.c b/drivers/accel/ivpu/ 
>> ivpu_fw_log.c
>> index 337c906b0210..275baf844b56 100644
>> --- a/drivers/accel/ivpu/ivpu_fw_log.c
>> +++ b/drivers/accel/ivpu/ivpu_fw_log.c
>> @@ -98,6 +98,11 @@ static void fw_log_print_buffer(struct 
>> vpu_tracing_buffer_header *log, const cha
>>       u32 log_start = only_new_msgs ? READ_ONCE(log->read_index) : 0;
>>       u32 log_end = READ_ONCE(log->write_index);
>> +    if (log_start >= data_size)
>> +        log_start = 0;
>> +    if (log_end > data_size)
>> +        log_end = data_size;
>> +
>>       if (log->wrap_count == log->read_wrap_count) {
>>           if (log_end <= log_start) {
>>               drm_printf(p, "==== %s \"%s\" log empty ====\n", prefix, 
>> log->name);
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-02  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 11:58 [PATCH] accel/ivpu: Add bounds checks for firmware log indices Andrzej Kacprowski
2026-05-29 12:06 ` Wachowski, Karol
2026-06-02  5:49   ` Wachowski, Karol

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.