Skip to content

Commit 901ec34

Browse files
committed
accel/amdxdna: Validate command buffer payload count
The count field in the command header is used to determine the valid payload size. Verify that the valid payload does not exceed the remaining buffer space. Fixes: aac2430 ("accel/amdxdna: Add command execution") Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20260219211946.1920485-1-lizhi.hou@amd.com
1 parent 03808ab commit 901ec34

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/accel/amdxdna/amdxdna_ctx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ void *amdxdna_cmd_get_payload(struct amdxdna_gem_obj *abo, u32 *size)
104104

105105
if (size) {
106106
count = FIELD_GET(AMDXDNA_CMD_COUNT, cmd->header);
107-
if (unlikely(count <= num_masks)) {
107+
if (unlikely(count <= num_masks ||
108+
count * sizeof(u32) +
109+
offsetof(struct amdxdna_cmd, data[0]) >
110+
abo->mem.size)) {
108111
*size = 0;
109112
return NULL;
110113
}

0 commit comments

Comments
 (0)