mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 2/4] firmware: qcom: scm: take struct device as argument in SHM bridge enable
Date: Wed, 25 Jun 2025 14:08:48 +0200	[thread overview]
Message-ID: <b1db543e-f33e-4162-8de1-257084d282de@oss.qualcomm.com> (raw)
In-Reply-To: <20250625-qcom-scm-race-v1-2-45601e1f248b@linaro.org>

On 6/25/25 10:14 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> qcom_scm_shm_bridge_enable() is used early in the SCM initialization
> routine. It makes an SCM call and so expects the internal __scm pointer
> in the SCM driver to be assigned. For this reason the tzmem memory pool
> is allocated *after* this pointer is assigned. However, this can lead to
> a crash if another consumer of the SCM API makes a call using the memory
> pool between the assignment of the __scm pointer and the initialization
> of the tzmem memory pool.
> 
> As qcom_scm_shm_bridge_enable() is a special case, not meant to be
> called by ordinary users, pull it into the local SCM header. Make it
> take struct device as argument. This is the device that will be used to
> make the SCM call as opposed to the global __scm pointer. This will
> allow us to move the tzmem initialization *before* the __scm assignment
> in the core SCM driver.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---

I think you'll most definitely want to leave some comment about this
intertwined chain, or someone is sure to break it in the future when
doing some sort of refactoring

Konrad

  reply	other threads:[~2025-06-25 12:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25  8:14 [PATCH 0/4] firmware: qcom: scm: fix potential race condition with tzmem Bartosz Golaszewski
2025-06-25  8:14 ` [PATCH 1/4] firmware: qcom: scm: remove unused arguments from SHM bridge routines Bartosz Golaszewski
2025-06-25 12:01   ` Konrad Dybcio
2025-06-25  8:14 ` [PATCH 2/4] firmware: qcom: scm: take struct device as argument in SHM bridge enable Bartosz Golaszewski
2025-06-25 12:08   ` Konrad Dybcio [this message]
2025-06-25  8:14 ` [PATCH 3/4] firmware: qcom: scm: initialize tzmem before marking SCM as available Bartosz Golaszewski
2025-06-25 14:39   ` Johan Hovold
2025-06-25 14:47   ` Konrad Dybcio
2025-06-25 14:55     ` Bartosz Golaszewski
2025-06-25  8:14 ` [PATCH 4/4] firmware: qcom: scm: request the waitqueue irq *after* initializing SCM Bartosz Golaszewski
2025-06-25 14:49   ` Konrad Dybcio

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=b1db543e-f33e-4162-8de1-257084d282de@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®