* [PATCH 5.10.y] cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate()
@ 2025-09-12 20:35 Sergey Shtylyov
2025-09-16 19:04 ` Sergey Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Shtylyov @ 2025-09-12 20:35 UTC (permalink / raw)
To: stable, linux-kernel
Cc: Henry Martin, Sudeep Holla, Viresh Kumar, lvc-project
From: Henry Martin <bsdhenrymartin@gmail.com>
[ Upstream commit 484d3f15cc6cbaa52541d6259778e715b2c83c54 ]
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present
in the policy->cpus mask. scmi_cpufreq_get_rate() does not check for
this case, which results in a NULL pointer dereference.
Add NULL check after cpufreq_cpu_get_raw() to prevent this issue.
[Sergey: resolved reject (reordering the local variables).]
Fixes: 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI message protocol")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Index: linux-stable/drivers/cpufreq/scmi-cpufreq.c
===================================================================
--- linux-stable.orig/drivers/cpufreq/scmi-cpufreq.c
+++ linux-stable/drivers/cpufreq/scmi-cpufreq.c
@@ -29,12 +29,18 @@ static const struct scmi_handle *handle;
static unsigned int scmi_cpufreq_get_rate(unsigned int cpu)
{
- struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
const struct scmi_perf_ops *perf_ops = handle->perf_ops;
- struct scmi_data *priv = policy->driver_data;
+ struct cpufreq_policy *policy;
+ struct scmi_data *priv;
unsigned long rate;
int ret;
+ policy = cpufreq_cpu_get_raw(cpu);
+ if (unlikely(!policy))
+ return 0;
+
+ priv = policy->driver_data;
+
ret = perf_ops->freq_get(handle, priv->domain_id, &rate, false);
if (ret)
return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 5.10.y] cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate()
2025-09-12 20:35 [PATCH 5.10.y] cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate() Sergey Shtylyov
@ 2025-09-16 19:04 ` Sergey Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Shtylyov @ 2025-09-16 19:04 UTC (permalink / raw)
To: stable, linux-kernel
Cc: Henry Martin, Sudeep Holla, Viresh Kumar, lvc-project
On 9/12/25 11:35 PM, Sergey Shtylyov wrote:
> From: Henry Martin <bsdhenrymartin@gmail.com>
>
> [ Upstream commit 484d3f15cc6cbaa52541d6259778e715b2c83c54 ]
>
> cpufreq_cpu_get_raw() can return NULL when the target CPU is not present
> in the policy->cpus mask. scmi_cpufreq_get_rate() does not check for
> this case, which results in a NULL pointer dereference.
>
> Add NULL check after cpufreq_cpu_get_raw() to prevent this issue.
>
> [Sergey: resolved reject (reordering the local variables).]
>
> Fixes: 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI message protocol")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Probably should have noted that this patch fixes CVE-2025-37830:
https://marc.info/?l=linux-cve-announce&m=174668615621702
(Sorry, lore doesn't work for me anymre...]
MBR, Sergey
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-16 19:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12 20:35 [PATCH 5.10.y] cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate() Sergey Shtylyov
2025-09-16 19:04 ` Sergey Shtylyov
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®