lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <oq7on5krzvq2lsla4irfi4cr2lwnzejpowglzmovon7ye4dgsm@yqibu2el6j3l>
Date: Tue, 26 Nov 2024 22:45:38 -0600
From: Bjorn Andersson <andersson@...nel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Cc: Bartosz Golaszewski <brgl@...ev.pl>, 
	Konrad Dybcio <konradybcio@...nel.org>, Mukesh Ojha <quic_mojha@...cinc.com>, 
	Dmitry Baryshkov <dmitry.baryshkov@...aro.org>, Stephan Gerhold <stephan.gerhold@...aro.org>, 
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, Kuldeep Singh <quic_kuldsing@...cinc.com>, 
	Elliot Berman <quic_eberman@...cinc.com>, Andrew Halaney <ahalaney@...hat.com>, 
	Avaneesh Kumar Dwivedi <quic_akdwived@...cinc.com>, Andy Gross <andy.gross@...aro.org>, 
	linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/6] firmware: qcom: scm: Handle various probe ordering
 for qcom_scm_assign_mem()

On Wed, Nov 20, 2024 at 03:19:00PM +0100, Krzysztof Kozlowski wrote:
> On 20/11/2024 15:07, Bartosz Golaszewski wrote:
> >> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> >> index 5d91b8e22844608f35432f1ba9c08d477d4ff762..93212c8f20ad65ecc44804b00f4b93e3eaaf8d95 100644
> >> --- a/drivers/firmware/qcom/qcom_scm.c
> >> +++ b/drivers/firmware/qcom/qcom_scm.c
> >> @@ -1075,6 +1075,9 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
> >>         int ret, i, b;
> >>         u64 srcvm_bits = *srcvm;
> >>
> >> +       if (!qcom_scm_is_available())
> >> +               return -EPROBE_DEFER;
> >> +
> > 
> > Should we be returning -EPROBE_DEFER from functions that are not
> > necessarily limited to being used in probe()? For instance ath10k uses
> > it in a workqueue job. I think this is why this driver is probed in
> > subsys_initcall() rather than module_initcall().
> Uh, good point. To my understanding, every resource like function can do
> it, e.g. clk_get. Whether drivers call it in probe() or somewhere else -
> e.g. some startup call like there is plenty in the ASoC or DMA
> device_alloc_chan_resources() - is responsibility of the
> driver/consumer, not the provider of that resource.
> 
> With such explanation returning EPROBE_DEFER is ok, just like returning
> anything else (e.g. EINVAL).
> 
> Now about this function: it is not exactly "get a resource" one, but
> still the caller might want to call it again later, which is implied by
> EPROBE_DEFER. Maybe this should be EAGAIN instead? Just like
> power-supply is doing in power_supply_get_property().
> 

The return value here will wander up the stack and I'm not convinced
that all callers will handle an EAGAIN in a favourable way.

The way we've dealt with this before is to say that if a client will
call qcom_scm_*() they must call qcom_scm_is_available() during their
initialization and handle the EPROBE_DEFER accordingly.

Regards,
Bjorn

> Best regards,
> Krzysztof

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ