mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Guru Das Srinagesh <linux@gurudas.dev>,
	Sibi Sankar <sibi.sankar@oss.qualcomm.com>,
	Elliot Berman <quic_eberman@quicinc.com>,
	Andrew Halaney <ahalaney@redhat.com>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] firmware: qcom: scm: Fix NULL dereference in IRQ handler before __scm is published
Date: Tue, 30 Jun 2026 11:50:30 +0200	[thread overview]
Message-ID: <6f8e6b61-a6cd-490f-84d8-9ddb8638d952@oss.qualcomm.com> (raw)
In-Reply-To: <20260629141750.996853-2-mukesh.ojha@oss.qualcomm.com>

On 6/29/26 4:17 PM, Mukesh Ojha wrote:
> In qcom_scm_probe(), devm_request_threaded_irq() is called before
> smp_store_release(&__scm, scm). Two paths can dereference __scm before
> it is published, both causing a NULL pointer dereference.
> 
> The IRQ handler receives scm via its data argument but passes only wq_ctx
> to qcom_scm_waitq_wakeup() and qcom_scm_get_completion(), which then
> dereference __scm directly. Thread scm through both functions so the IRQ
> handler path never touches __scm.
> 
> Non-atomic SMC calls made during probe (e.g. from qcom_tzmem_init via
> qcom_scm_shm_bridge_enable) can return WAITQ_SLEEP, causing
> qcom_scm_wait_for_wq_completion() to run before __scm is published and
> dereference it. Add platform_set_drvdata(pdev, scm) early in probe and
> change qcom_scm_wait_for_wq_completion() to take the device pointer and
> use dev_get_drvdata() to reach scm, removing any dependency on __scm.
> 
> Fixes: 6bf325992236 ("firmware: qcom: scm: Add wait-queue handling logic")
> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
> ---

[...]

> -int qcom_scm_wait_for_wq_completion(u32 wq_ctx)
> +int qcom_scm_wait_for_wq_completion(struct device *dev, u32 wq_ctx)

I think it logically makes more sense to pass a struct qcom_scm* here
and get the data from the caller, but potayto/potato

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

  reply	other threads:[~2026-06-30  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 14:17 [PATCH v2 0/3] Misc. SCM driver fixes Mukesh Ojha
2026-06-29 14:17 ` [PATCH v2 1/3] firmware: qcom: scm: Fix NULL dereference in IRQ handler before __scm is published Mukesh Ojha
2026-06-30  9:50   ` Konrad Dybcio [this message]
2026-06-30 10:07     ` Mukesh Ojha
2026-06-29 14:17 ` [PATCH v2 2/3] firmware: qcom: scm: Fix reserved memory cleanup on probe failure Mukesh Ojha
2026-06-30 10:07   ` Konrad Dybcio
2026-07-02 10:28     ` Mukesh Ojha
2026-06-29 14:17 ` [PATCH v2 3/3] firmware: qcom: scm: Fix tzmem state on probe retry Mukesh Ojha
2026-06-30 10:12   ` Konrad Dybcio
2026-06-30 13:50 ` [PATCH v2 0/3] Misc. SCM driver fixes Bartosz Golaszewski

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=6f8e6b61-a6cd-490f-84d8-9ddb8638d952@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=ahalaney@redhat.com \
    --cc=andersson@kernel.org \
    --cc=brgl@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@gurudas.dev \
    --cc=mukesh.ojha@oss.qualcomm.com \
    --cc=quic_eberman@quicinc.com \
    --cc=sibi.sankar@oss.qualcomm.com \
    /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 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®