From: Xixin Liu <liuxixin@kylinos.cn>
To: arm-scmi@vger.kernel.org
Cc: sudeep.holla@arm.com, cristian.marussi@arm.com,
mturquette@baylibre.com, sboyd@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, liuxixin@kylinos.cn
Subject: [PATCH v1 2/4] firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS
Date: Mon, 27 Jul 2026 10:19:15 +0800 [thread overview]
Message-ID: <bfebdb68118c.1785118770.git.liuxixin@kylinos.cn> (raw)
In-Reply-To: <cover.1785118770.git.liuxixin@kylinos.cn>
scpi_dvfs_get_info() already rejected a zero opp_count, but still trusted
any larger value from the SCP firmware. The shared-memory reply only holds
MAX_DVFS_OPPS entries in buf.opps[]; a bigger count over-reads that array
and then sizes the allocated OPP table incorrectly (garbage OPPs / OOB).
Reject zero and out-of-range counts in one check and return -EINVAL.
Signed-off-by: Xixin Liu <liuxixin@kylinos.cn>
---
drivers/firmware/arm_scpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 6056754ef48c..5db58bdfc947 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -630,8 +630,8 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)
if (ret)
return ERR_PTR(ret);
- if (!buf.opp_count)
- return ERR_PTR(-ENOENT);
+ if (!buf.opp_count || buf.opp_count > MAX_DVFS_OPPS)
+ return ERR_PTR(-EINVAL);
info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info)
--
2.53.0
next prev parent reply other threads:[~2026-07-27 2:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 2:19 [PATCH v1 0/4] firmware/clk: arm_scpi hardening (leak, OPP bounds, cpufreq) Xixin Liu
2026-07-27 2:19 ` [PATCH v1 1/4] firmware: arm_scpi: fix device_node leak in scpi_dev_domain_id Xixin Liu
2026-07-27 2:19 ` Xixin Liu [this message]
2026-07-27 19:49 ` [PATCH v1 2/4] firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS Sudeep Holla
2026-07-27 19:59 ` Sudeep Holla
2026-07-27 2:19 ` [PATCH v1 3/4] clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate Xixin Liu
2026-07-27 20:01 ` Sudeep Holla
2026-07-27 2:19 ` [PATCH v1 4/4] clk: scpi: register scpi-cpufreq once and clear on failure Xixin Liu
2026-07-27 20:06 ` Sudeep Holla
2026-07-28 1:04 ` [PATCH v2 0/5] firmware/clk: arm_scpi hardening (leak, OPP bounds, cpufreq) Xixin Liu
2026-07-28 0:50 ` [PATCH v2 4/5] clk: scpi: register scpi-cpufreq once and clear on failure Xixin Liu
2026-07-28 0:50 ` [PATCH v2 3/5] clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate Xixin Liu
2026-07-28 0:50 ` [PATCH v2 2/5] firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS Xixin Liu
2026-07-28 0:50 ` [PATCH v2 1/5] firmware: arm_scpi: fix device_node leak in scpi_dev_domain_id Xixin Liu
2026-07-28 1:27 ` [PATCH v2 5/5] clk: scpi: use PLATFORM_DEVID_NONE for scpi-cpufreq Xixin Liu
2026-07-28 9:52 ` Sudeep Holla
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=bfebdb68118c.1785118770.git.liuxixin@kylinos.cn \
--to=liuxixin@kylinos.cn \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=sudeep.holla@arm.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®