* [PATCH V1] accel/amdxdna: Remove __counted_by from struct amdxdna_cmd_chain
@ 2026-08-21 3:35 Lizhi Hou
2026-08-21 17:50 ` Max Zhen
0 siblings, 1 reply; 3+ messages in thread
From: Lizhi Hou @ 2026-08-21 3:35 UTC (permalink / raw)
To: ogabbay, quic_jhugo, dri-devel, mario.limonciello, karol.wachowski
Cc: Lizhi Hou, linux-kernel, max.zhen, sonal.santan
struct amdxdna_cmd_chain contains a flexible array annotated with
__counted_by(command_count). Since the structure is stored in shared
AMDXDNA_BO_SHARE memory, userspace can modify command_count concurrently.
If command_count is changed to zero, the bounds check generated from
__counted_by may fail and trigger a kernel panic.
Remove __counted_by to avoid relying on the userspace-controlled
command_count for the flexible array bounds check.
Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/accel/amdxdna/amdxdna_ctx.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/accel/amdxdna/amdxdna_ctx.h b/drivers/accel/amdxdna/amdxdna_ctx.h
index e6155f4b5db0..010538cb05a3 100644
--- a/drivers/accel/amdxdna/amdxdna_ctx.h
+++ b/drivers/accel/amdxdna/amdxdna_ctx.h
@@ -56,7 +56,7 @@ struct amdxdna_cmd_chain {
u32 submit_index;
u32 error_index;
u32 reserved[3];
- u64 data[] __counted_by(command_count);
+ u64 data[];
};
/*
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V1] accel/amdxdna: Remove __counted_by from struct amdxdna_cmd_chain
2026-08-21 3:35 [PATCH V1] accel/amdxdna: Remove __counted_by from struct amdxdna_cmd_chain Lizhi Hou
@ 2026-08-21 17:50 ` Max Zhen
2026-08-24 16:39 ` Lizhi Hou
0 siblings, 1 reply; 3+ messages in thread
From: Max Zhen @ 2026-08-21 17:50 UTC (permalink / raw)
To: Lizhi Hou, ogabbay, quic_jhugo, dri-devel, mario.limonciello,
karol.wachowski
Cc: linux-kernel, sonal.santan
On 8/20/2026 Thu 20:35, Lizhi Hou wrote:
> struct amdxdna_cmd_chain contains a flexible array annotated with
> __counted_by(command_count). Since the structure is stored in shared
> AMDXDNA_BO_SHARE memory, userspace can modify command_count concurrently.
> If command_count is changed to zero, the bounds check generated from
> __counted_by may fail and trigger a kernel panic.
>
> Remove __counted_by to avoid relying on the userspace-controlled
> command_count for the flexible array bounds check.
>
> Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
> drivers/accel/amdxdna/amdxdna_ctx.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.h b/drivers/accel/amdxdna/amdxdna_ctx.h
> index e6155f4b5db0..010538cb05a3 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.h
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.h
> @@ -56,7 +56,7 @@ struct amdxdna_cmd_chain {
> u32 submit_index;
> u32 error_index;
> u32 reserved[3];
> - u64 data[] __counted_by(command_count);
> + u64 data[];
> };
>
> /*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V1] accel/amdxdna: Remove __counted_by from struct amdxdna_cmd_chain
2026-08-21 17:50 ` Max Zhen
@ 2026-08-24 16:39 ` Lizhi Hou
0 siblings, 0 replies; 3+ messages in thread
From: Lizhi Hou @ 2026-08-24 16:39 UTC (permalink / raw)
To: Max Zhen, ogabbay, quic_jhugo, dri-devel, mario.limonciello,
karol.wachowski
Cc: linux-kernel, sonal.santan
Applied to drm-misc-fixes.
On 8/21/26 10:50, Max Zhen wrote:
>
>
> On 8/20/2026 Thu 20:35, Lizhi Hou wrote:
>> struct amdxdna_cmd_chain contains a flexible array annotated with
>> __counted_by(command_count). Since the structure is stored in shared
>> AMDXDNA_BO_SHARE memory, userspace can modify command_count
>> concurrently.
>> If command_count is changed to zero, the bounds check generated from
>> __counted_by may fail and trigger a kernel panic.
>>
>> Remove __counted_by to avoid relying on the userspace-controlled
>> command_count for the flexible array bounds check.
>>
>> Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Reviewed-by: Max Zhen <max.zhen@amd.com>
>> ---
>> drivers/accel/amdxdna/amdxdna_ctx.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.h
>> b/drivers/accel/amdxdna/amdxdna_ctx.h
>> index e6155f4b5db0..010538cb05a3 100644
>> --- a/drivers/accel/amdxdna/amdxdna_ctx.h
>> +++ b/drivers/accel/amdxdna/amdxdna_ctx.h
>> @@ -56,7 +56,7 @@ struct amdxdna_cmd_chain {
>> u32 submit_index;
>> u32 error_index;
>> u32 reserved[3];
>> - u64 data[] __counted_by(command_count);
>> + u64 data[];
>> };
>> /*
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-24 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 3:35 [PATCH V1] accel/amdxdna: Remove __counted_by from struct amdxdna_cmd_chain Lizhi Hou
2026-08-21 17:50 ` Max Zhen
2026-08-24 16:39 ` Lizhi Hou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®