Skip to content

Commit 773ba5b

Browse files
committed
firmware: arm_scpi: Fix string overflow in SCPI genpd driver
jira LE-3201 cve CVE-2021-47609 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Sudeep Holla <sudeep.holla@arm.com> commit 865ed67 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-4.18.0-553.22.1.rt7.363.el8_10/865ed67a.failed Without the bound checks for scpi_pd->name, it could result in the buffer overflow when copying the SCPI device name from the corresponding device tree node as the name string is set at maximum size of 30. Let us fix it by using devm_kasprintf so that the string buffer is allocated dynamically. Fixes: 8bec433 ("firmware: scpi: add device power domain support using genpd") Reported-by: Pedro Batista <pedbap.g@gmail.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Cc: stable@vger.kernel.org Cc: Cristian Marussi <cristian.marussi@arm.com> Link: https://lore.kernel.org/r/20211209120456.696879-1-sudeep.holla@arm.com' Signed-off-by: Arnd Bergmann <arnd@arndb.de> (cherry picked from commit 865ed67) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # drivers/firmware/scpi_pm_domain.c
1 parent ea60cd5 commit 773ba5b

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
firmware: arm_scpi: Fix string overflow in SCPI genpd driver
2+
3+
jira LE-3201
4+
cve CVE-2021-47609
5+
Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10
6+
commit-author Sudeep Holla <sudeep.holla@arm.com>
7+
commit 865ed67ab955428b9aa771d8b4f1e4fb7fd08945
8+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
9+
Will be included in final tarball splat. Ref for failed cherry-pick at:
10+
ciq/ciq_backports/kernel-rt-4.18.0-553.22.1.rt7.363.el8_10/865ed67a.failed
11+
12+
Without the bound checks for scpi_pd->name, it could result in the buffer
13+
overflow when copying the SCPI device name from the corresponding device
14+
tree node as the name string is set at maximum size of 30.
15+
16+
Let us fix it by using devm_kasprintf so that the string buffer is
17+
allocated dynamically.
18+
19+
Fixes: 8bec4337ad40 ("firmware: scpi: add device power domain support using genpd")
20+
Reported-by: Pedro Batista <pedbap.g@gmail.com>
21+
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
22+
Cc: stable@vger.kernel.org
23+
Cc: Cristian Marussi <cristian.marussi@arm.com>
24+
Link: https://lore.kernel.org/r/20211209120456.696879-1-sudeep.holla@arm.com'
25+
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
26+
(cherry picked from commit 865ed67ab955428b9aa771d8b4f1e4fb7fd08945)
27+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
28+
29+
# Conflicts:
30+
# drivers/firmware/scpi_pm_domain.c
31+
diff --cc drivers/firmware/scpi_pm_domain.c
32+
index f395dec27113,800673910b51..000000000000
33+
--- a/drivers/firmware/scpi_pm_domain.c
34+
+++ b/drivers/firmware/scpi_pm_domain.c
35+
@@@ -121,8 -109,13 +120,18 @@@ static int scpi_pm_domain_probe(struct
36+
37+
scpi_pd->domain = i;
38+
scpi_pd->ops = scpi_ops;
39+
++<<<<<<< HEAD
40+
+ sprintf(scpi_pd->name, "%s.%d", np->name, i);
41+
+ scpi_pd->genpd.name = scpi_pd->name;
42+
++=======
43+
+ scpi_pd->genpd.name = devm_kasprintf(dev, GFP_KERNEL,
44+
+ "%pOFn.%d", np, i);
45+
+ if (!scpi_pd->genpd.name) {
46+
+ dev_err(dev, "Failed to allocate genpd name:%pOFn.%d\n",
47+
+ np, i);
48+
+ continue;
49+
+ }
50+
++>>>>>>> 865ed67ab955 (firmware: arm_scpi: Fix string overflow in SCPI genpd driver)
51+
scpi_pd->genpd.power_off = scpi_pd_power_off;
52+
scpi_pd->genpd.power_on = scpi_pd_power_on;
53+
54+
* Unmerged path drivers/firmware/scpi_pm_domain.c

0 commit comments

Comments
 (0)