From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
media-ci@linuxtv.org, robh@kernel.org
Subject: Re: [PATCH v10 04/14] media: iris: Add helper to select relevant context bank device
Date: Sun, 26 Jul 2026 06:11:55 +0000 [thread overview]
Message-ID: <20260726061156.109A51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260726-glymur-v10-4-de451559e88b@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Severe Use-After-Free in firmware response handler because `v4l2_m2m_ctx_release` frees the context before the firmware session is closed.
- [High] Unprotected list iteration on V4L2 ready queues causes data races and list corruption.
--
--- Patch [4]: [PATCH v10 04/14] media: iris: Add helper to select relevant context bank device ---
commit 694c94b16bf3fad4b4fbf3ea9de787f2ecf1a955
Author: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Subject: media: iris: Add helper to select relevant context bank device
This commit introduces a helper to associate context bank devices with
respective buffers in the iris driver. It also adds a fallback to the
core device when the platform describes the IOMMU on the parent node.
> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
> index 14d63dc76c9ba..26df872fb4fa1 100644
> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
[ ... ]
> @@ -121,7 +121,7 @@ iris_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_
> dst_vq->drv_priv = inst;
> dst_vq->buf_struct_size = sizeof(struct iris_buffer);
> dst_vq->min_reqbufs_allocation = MIN_BUFFERS;
> - dst_vq->dev = inst->core->dev;
> + dst_vq->dev = iris_get_cb_dev(inst, BUF_OUTPUT);
> dst_vq->lock = &inst->ctx_q_lock;
>
> return vb2_queue_init(dst_vq);
[Severity: Critical]
This isn't a bug introduced by this patch, but is there a use-after-free
regression during device closure in iris_close()?
When a userspace application closes the device FD, iris_close() invokes
v4l2_m2m_ctx_release() which immediately frees the memory-to-memory context:
drivers/media/platform/qcom/iris/iris_vidc.c:iris_close() {
...
v4l2_m2m_ctx_release(inst->m2m_ctx);
...
}
However, this happens before the firmware session is closed and before the
instance is removed from the global core->instances list. If the firmware
asynchronously sends a response (e.g., HFI_CMD_BUFFER) during this window,
can the IRQ handler in iris_hfi_gen2_handle_output_buffer() look up the
instance and dereference the freed inst->m2m_ctx?
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c:iris_hfi_gen2_handle_output_buffer() {
...
struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
...
v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, m2m_buffer, n) {
...
}
[Severity: High]
This isn't a bug introduced by this patch, but could this list iteration cause
a data race resulting in corruption of the V4L2 ready queues?
In driver functions like iris_hfi_gen2_handle_dequeue_buffers(), the ready
queue is iterated without holding the queue-specific rdy_spinlock:
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c:iris_hfi_gen2_handle_dequeue_buffers() {
...
v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buffer, n) {
...
}
Concurrently, userspace operations like VIDIOC_QBUF can call
v4l2_m2m_buf_queue(), which modifies the list under rdy_spinlock:
drivers/media/v4l2-core/v4l2-mem2mem.c:v4l2_m2m_buf_queue() {
...
spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
list_add_tail(&b->list, &q_ctx->rdy_queue);
...
}
Since the driver's lockless list iteration races directly with list
modifications from the V4L2 core, might this lead to corrupted list pointers
when QBUF or STREAMOFF execute concurrently with firmware responses?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260726-glymur-v10-0-de451559e88b@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-07-26 6:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 5:49 [PATCH v10 00/14] media: iris: Add support for glymur platform Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 01/14] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-07-26 6:00 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 02/14] media: iris: Add hooks to initialize and tear down context banks Vishnu Reddy
2026-07-26 6:01 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 03/14] media: iris: Add helper to create a context bank device Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 04/14] media: iris: Add helper to select relevant " Vishnu Reddy
2026-07-26 6:11 ` sashiko-bot [this message]
2026-07-26 5:49 ` [PATCH v10 05/14] media: iris: Skip DMA mask setting to core device when IOMMU is not mapped Vishnu Reddy
2026-07-26 6:05 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-07-26 6:08 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 07/14] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-07-26 6:06 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 08/14] media: iris: Add power sequence for glymur Vishnu Reddy
2026-07-26 6:05 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 09/14] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 10/14] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-07-26 6:18 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 11/14] media: iris: Add hooks for pixel and non-pixel context banks Vishnu Reddy
2026-07-26 6:03 ` sashiko-bot
2026-07-26 5:49 ` [PATCH v10 12/14] media: iris: Add platform data for glymur Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 13/14] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-07-26 5:49 ` [PATCH v10 14/14] arm64: dts: qcom: glymur-crd: Enable iris video codec node Vishnu Reddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260726061156.109A51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.