[PATCH 1/2] media: iris: check the packet size after reading from shared memory
From: Hungyu Lin
Date: Tue Nov 17 2026 - 15:50:18 EST
iris_hfi_queue_read() takes the size of a packet from the first word of
the packet in the shared queue and then copies that many bytes, including
that word, out of the queue. The firmware can change the word in between,
so the size field of the copy can be larger than what was copied. The
gen1 response handlers use that field as the length of the packet, for
example to walk the buffer requirements in
iris_hfi_gen1_session_property_info().
venus got the same check in commit 49befc830daa ("media: venus: Add a
check for packet size after reading from shared memory"). Compare the
size field of the copy with the size that was used for the copy and fail
the read if they differ.
Fixes: fb583a214337 ("media: iris: introduce host firmware interface with necessary hooks")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
---
drivers/media/platform/qcom/iris/iris_hfi_queue.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_queue.c b/drivers/media/platform/qcom/iris/iris_hfi_queue.c
index bf6db23b53e2..5d3315f71623 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_queue.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_queue.c
@@ -95,6 +95,8 @@ static int iris_hfi_queue_read(struct iris_iface_q_info *qinfo, void *packet)
qinfo->kernel_vaddr, residue);
new_read_idx = residue;
}
+ if (*(u32 *)packet != packet_size)
+ return -EINVAL;
} else {
new_read_idx = write_idx;
ret = -EBADMSG;
--
2.43.0