Skip to content

Commit 3136b9e

Browse files
committed
firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails
jira LE-4321 cve CVE-2022-50087 Rebuild_History Non-Buildable kernel-4.18.0-553.77.1.el8_10 commit-author Sudeep Holla <sudeep.holla@arm.com> commit 689640e 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-4.18.0-553.77.1.el8_10/689640ef.failed When scpi probe fails, at any point, we need to ensure that the scpi_info is not set and will remain NULL until the probe succeeds. If it is not taken care, then it could result use-after-free as the value is exported via get_scpi_ops() and could refer to a memory allocated via devm_kzalloc() but freed when the probe fails. Link: https://lore.kernel.org/r/20220701160310.148344-1-sudeep.holla@arm.com Cc: stable@vger.kernel.org # 4.19+ Reported-by: huhai <huhai@kylinos.cn> Reviewed-by: Jackie Liu <liuyun01@kylinos.cn> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> (cherry picked from commit 689640e) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # drivers/firmware/arm_scpi.c
1 parent 603ad23 commit 3136b9e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails
2+
3+
jira LE-4321
4+
cve CVE-2022-50087
5+
Rebuild_History Non-Buildable kernel-4.18.0-553.77.1.el8_10
6+
commit-author Sudeep Holla <sudeep.holla@arm.com>
7+
commit 689640efc0a2c4e07e6f88affe6d42cd40cc3f85
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-4.18.0-553.77.1.el8_10/689640ef.failed
11+
12+
When scpi probe fails, at any point, we need to ensure that the scpi_info
13+
is not set and will remain NULL until the probe succeeds. If it is not
14+
taken care, then it could result use-after-free as the value is exported
15+
via get_scpi_ops() and could refer to a memory allocated via devm_kzalloc()
16+
but freed when the probe fails.
17+
18+
Link: https://lore.kernel.org/r/20220701160310.148344-1-sudeep.holla@arm.com
19+
Cc: stable@vger.kernel.org # 4.19+
20+
Reported-by: huhai <huhai@kylinos.cn>
21+
Reviewed-by: Jackie Liu <liuyun01@kylinos.cn>
22+
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
23+
(cherry picked from commit 689640efc0a2c4e07e6f88affe6d42cd40cc3f85)
24+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
25+
26+
# Conflicts:
27+
# drivers/firmware/arm_scpi.c
28+
diff --cc drivers/firmware/arm_scpi.c
29+
index c7d06a36b23a,435d0e2658a4..000000000000
30+
--- a/drivers/firmware/arm_scpi.c
31+
+++ b/drivers/firmware/arm_scpi.c
32+
@@@ -1011,22 -1017,23 +1015,31 @@@ static int scpi_probe(struct platform_d
33+
else
34+
dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
35+
FIELD_GET(PROTO_REV_MAJOR_MASK,
36+
- scpi_info->protocol_version),
37+
+ scpi_drvinfo->protocol_version),
38+
FIELD_GET(PROTO_REV_MINOR_MASK,
39+
- scpi_info->protocol_version),
40+
+ scpi_drvinfo->protocol_version),
41+
FIELD_GET(FW_REV_MAJOR_MASK,
42+
- scpi_info->firmware_version),
43+
+ scpi_drvinfo->firmware_version),
44+
FIELD_GET(FW_REV_MINOR_MASK,
45+
- scpi_info->firmware_version),
46+
+ scpi_drvinfo->firmware_version),
47+
FIELD_GET(FW_REV_PATCH_MASK,
48+
- scpi_info->firmware_version));
49+
- scpi_info->scpi_ops = &scpi_ops;
50+
+ scpi_drvinfo->firmware_version));
51+
52+
++<<<<<<< HEAD
53+
+ ret = devm_device_add_groups(dev, versions_groups);
54+
+ if (ret)
55+
+ dev_err(dev, "unable to create sysfs version group\n");
56+
+
57+
+ return devm_of_platform_populate(dev);
58+
++=======
59+
+ scpi_drvinfo->scpi_ops = &scpi_ops;
60+
+
61+
+ ret = devm_of_platform_populate(dev);
62+
+ if (ret)
63+
+ scpi_info = NULL;
64+
+
65+
+ return ret;
66+
++>>>>>>> 689640efc0a2 (firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails)
67+
}
68+
69+
static const struct of_device_id scpi_of_match[] = {
70+
* Unmerged path drivers/firmware/arm_scpi.c

0 commit comments

Comments
 (0)