All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 11/16] media: iris: update buffer requirements based on received info
Date: Tue, 16 Jun 2026 00:20:01 +0000	[thread overview]
Message-ID: <20260616002001.E6F641F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260616-iris-ar50lt-v5-11-583b42770b6a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Concurrent handling of HFI response packets and instance teardown can result in a Use-After-Free (UAF) of `inst`.
--

commit 39194b5e5ad26925b8c03d02889401ec6e1fa21d
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

media: iris: update buffer requirements based on received info
    
Upon receiving data for HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS the
driver should update buffer sizes and counts from the received data.
This will be used for upcoming support of AR50Lt platforms.

> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
> index 23fc7194b1e3a..896953ea62ea4 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
[ ... ]
> @@ -657,7 +730,7 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
>  		} else if (hdr->pkt_type == HFI_MSG_SESSION_FILL_BUFFER) {
>  			iris_hfi_gen1_session_ftb_done(inst, hdr);
>  		} else if (hdr->pkt_type == HFI_MSG_SESSION_PROPERTY_INFO) {
> -			complete(&inst->completion);
> +			iris_hfi_gen1_session_property_info(inst, hdr);
>  		} else {
>  			struct hfi_msg_session_hdr_pkt *shdr;

[Severity: High]
This is a pre-existing issue, but can concurrent handling of HFI response
packets and instance teardown result in a use-after-free of the inst pointer?

Looking at the start of iris_hfi_gen1_handle_response(), it calls
iris_get_instance() which retrieves the inst pointer from the core list
without incrementing any reference count:

drivers/media/platform/qcom/iris/iris_utils.c:iris_get_instance() {
    list_for_each_entry(inst, &core->instances, list) {
        if (inst->session_id == session_id) {
            mutex_unlock(&core->lock);
            return inst;
        }
    }
}

The asynchronous response handler then blocks trying to acquire
mutex_lock(&inst->lock).

Concurrently, if iris_close() executes and calls iris_session_close(), it
can temporarily unlock inst->lock while waiting for the final 
HFI_MSG_SYS_SESSION_END response. This allows iris_close() to eventually
finish, remove the session, unlock and destroy the mutex, and free the
memory:

drivers/media/platform/qcom/iris/iris_vidc.c:iris_close() {
    iris_remove_session(inst);
    mutex_unlock(&inst->lock);
    mutex_destroy(&inst->ctx_q_lock);
    mutex_destroy(&inst->lock);
    ...
    kfree(inst);
}

If a spurious or trailing firmware message is processed for the same session,
the response handler could wake up when the lock is released by iris_close(),
successfully acquire the destroyed lock, and dereference the freed inst memory.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260616-iris-ar50lt-v5-0-583b42770b6a@oss.qualcomm.com?part=11

  reply	other threads:[~2026-06-16  0:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16  0:04 [PATCH v5 00/16] media: iris: Add AR50LT core support and enable Agatti platform Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 01/16] media: iris: Skip UBWC configuration when not supported Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 02/16] media: iris: Filter UBWC raw formats based on hardware capabilities Dmitry Baryshkov
2026-06-16  0:17   ` sashiko-bot
2026-06-16  0:32     ` Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 03/16] media: iris: Introduce set_preset_register as a vpu_op Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 04/16] media: iris: Introduce interrupt_init " Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 05/16] media: iris: add vpu op hook to disable ARP buffer Dmitry Baryshkov
2026-06-16  0:16   ` sashiko-bot
2026-06-16  0:04 ` [PATCH v5 06/16] media: iris: Add platform data field for watchdog interrupt mask Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 07/16] media: iris: Add platform flag for instantaneous bandwidth voting Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 08/16] media: iris: skip PIPE if it is not supported by the platform Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 09/16] media: iris: Add framework support for AR50_LITE video core Dmitry Baryshkov
2026-06-16  2:17   ` sashiko-bot
2026-06-16  0:04 ` [PATCH v5 10/16] media: iris: add minimal GET_PROPERTY implementation Dmitry Baryshkov
2026-06-16  0:20   ` sashiko-bot
2026-06-16  0:04 ` [PATCH v5 11/16] media: iris: update buffer requirements based on received info Dmitry Baryshkov
2026-06-16  0:20   ` sashiko-bot [this message]
2026-06-16  0:04 ` [PATCH v5 12/16] media: iris: implement support for the Agatti platform Dmitry Baryshkov
2026-06-16  0:40   ` sashiko-bot
2026-06-16  0:04 ` [PATCH v5 13/16] media: iris: Introduce buffer size calculations for AR50LT Dmitry Baryshkov
2026-06-16  0:21   ` sashiko-bot
2026-06-16  0:30     ` Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 14/16] media: iris: add Gen2 firmware support on the Agatti platform Dmitry Baryshkov
2026-06-16  0:26   ` sashiko-bot
2026-06-16  0:31     ` Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 15/16] media: venus: skip QCM2290 if Iris driver is enabled Dmitry Baryshkov
2026-06-16  0:04 ` [PATCH v5 16/16] media: iris: constify inst_fw_cap_sm8250_dec Dmitry Baryshkov

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=20260616002001.E6F641F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --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.