summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch')
-rw-r--r--meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch114
1 files changed, 114 insertions, 0 deletions
diff --git a/meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch b/meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch
new file mode 100644
index 0000000000..b0a16efeaa
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/CVE-2020-8432.patch
@@ -0,0 +1,114 @@
1From 5749faa3d6837d6dbaf2119fc3ec49a326690c8f Mon Sep 17 00:00:00 2001
2From: Tom Rini <trini@konsulko.com>
3Date: Tue, 21 Jan 2020 11:53:38 -0500
4Subject: [PATCH] cmd/gpt: Address error cases during gpt rename more correctly
5
6New analysis by the tool has shown that we have some cases where we
7weren't handling the error exit condition correctly. When we ran into
8the ENOMEM case we wouldn't exit the function and thus incorrect things
9could happen. Rework the unwinding such that we don't need a helper
10function now and free what we may have allocated.
11
12Fixes: 18030d04d25d ("GPT: fix memory leaks identified by Coverity")
13Reported-by: Coverity (CID: 275475, 275476)
14Cc: Alison Chaiken <alison@she-devel.com>
15Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
16Cc: Jordy <jordy@simplyhacker.com>
17Signed-off-by: Tom Rini <trini@konsulko.com>
18Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
19
20CVE: CVE-2020-8432
21Upstream-Status: Backport[https://github.com/u-boot/u-boot/commit/5749faa3d6837d6dbaf2119fc3ec49a326690c8f]
22Signed-off-by: Scott Murray <scott.murray@konsulko.com>
23
24---
25 cmd/gpt.c | 47 ++++++++++++-----------------------------------
26 1 file changed, 12 insertions(+), 35 deletions(-)
27
28diff --git a/cmd/gpt.c b/cmd/gpt.c
29index 0c4349f4b2..964702bad4 100644
30--- a/cmd/gpt.c
31+++ b/cmd/gpt.c
32@@ -633,21 +633,6 @@ static int do_disk_guid(struct blk_desc *dev_desc, char * const namestr)
33 }
34
35 #ifdef CONFIG_CMD_GPT_RENAME
36-/*
37- * There are 3 malloc() calls in set_gpt_info() and there is no info about which
38- * failed.
39- */
40-static void set_gpt_cleanup(char **str_disk_guid,
41- disk_partition_t **partitions)
42-{
43-#ifdef CONFIG_RANDOM_UUID
44- if (str_disk_guid)
45- free(str_disk_guid);
46-#endif
47- if (partitions)
48- free(partitions);
49-}
50-
51 static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
52 char *name1, char *name2)
53 {
54@@ -655,7 +640,7 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
55 struct disk_part *curr;
56 disk_partition_t *new_partitions = NULL;
57 char disk_guid[UUID_STR_LEN + 1];
58- char *partitions_list, *str_disk_guid;
59+ char *partitions_list, *str_disk_guid = NULL;
60 u8 part_count = 0;
61 int partlistlen, ret, numparts = 0, partnum, i = 1, ctr1 = 0, ctr2 = 0;
62
63@@ -697,14 +682,8 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
64 /* set_gpt_info allocates new_partitions and str_disk_guid */
65 ret = set_gpt_info(dev_desc, partitions_list, &str_disk_guid,
66 &new_partitions, &part_count);
67- if (ret < 0) {
68- del_gpt_info();
69- free(partitions_list);
70- if (ret == -ENOMEM)
71- set_gpt_cleanup(&str_disk_guid, &new_partitions);
72- else
73- goto out;
74- }
75+ if (ret < 0)
76+ goto out;
77
78 if (!strcmp(subcomm, "swap")) {
79 if ((strlen(name1) > PART_NAME_LEN) || (strlen(name2) > PART_NAME_LEN)) {
80@@ -766,14 +745,8 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
81 * Even though valid pointers are here passed into set_gpt_info(),
82 * it mallocs again, and there's no way to tell which failed.
83 */
84- if (ret < 0) {
85- del_gpt_info();
86- free(partitions_list);
87- if (ret == -ENOMEM)
88- set_gpt_cleanup(&str_disk_guid, &new_partitions);
89- else
90- goto out;
91- }
92+ if (ret < 0)
93+ goto out;
94
95 debug("Writing new partition table\n");
96 ret = gpt_restore(dev_desc, disk_guid, new_partitions, numparts);
97@@ -795,10 +768,14 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
98 }
99 printf("new partition table with %d partitions is:\n", numparts);
100 print_gpt_info();
101- del_gpt_info();
102 out:
103- free(new_partitions);
104- free(str_disk_guid);
105+ del_gpt_info();
106+#ifdef CONFIG_RANDOM_UUID
107+ if (str_disk_guid)
108+ free(str_disk_guid);
109+#endif
110+ if (new_partitions)
111+ free(new_partitions);
112 free(partitions_list);
113 return ret;
114 }