summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMarta Rybczynska <rybczynska@gmail.com>2022-02-18 11:05:38 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-02 00:21:37 +0000
commitacec862ed282c1242e41f9cce79104ace863d9a8 (patch)
tree697d1bd60fb20720aa7e09c1571cceb865824d61 /meta
parentbd3bda5d03504570b8f8520eb33d6806c407ef6f (diff)
downloadpoky-acec862ed282c1242e41f9cce79104ace863d9a8.tar.gz
grub: fix a memory leak
Add a fix of a memory leak in grub's commands/hashsum. It is a part of a security series [1]. [1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html (From OE-Core rev: de075f9421a16e1728968349ba16b0d68d47efea) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-bsp/grub/files/0030-commands-hashsum-Fix-a-memory-leak.patch56
-rw-r--r--meta/recipes-bsp/grub/grub2.inc1
2 files changed, 57 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0030-commands-hashsum-Fix-a-memory-leak.patch b/meta/recipes-bsp/grub/files/0030-commands-hashsum-Fix-a-memory-leak.patch
new file mode 100644
index 0000000000..e34a19e12c
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0030-commands-hashsum-Fix-a-memory-leak.patch
@@ -0,0 +1,56 @@
1From b136fa14d26d1833ffcb852f86e65da5960cfb99 Mon Sep 17 00:00:00 2001
2From: Chris Coulson <chris.coulson@canonical.com>
3Date: Tue, 1 Dec 2020 23:41:24 +0000
4Subject: [PATCH] commands/hashsum: Fix a memory leak
5
6check_list() uses grub_file_getline(), which allocates a buffer.
7If the hash list file contains invalid lines, the function leaks
8this buffer when it returns an error.
9
10Fixes: CID 176635
11
12Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
13Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
14
15Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=8b6f528e52e18b7a69f90b8dc3671d7b1147d9f3]
16Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
17---
18 grub-core/commands/hashsum.c | 15 ++++++++++++---
19 1 file changed, 12 insertions(+), 3 deletions(-)
20
21diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c
22index 456ba90..b8a22b0 100644
23--- a/grub-core/commands/hashsum.c
24+++ b/grub-core/commands/hashsum.c
25@@ -128,11 +128,17 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
26 high = hextoval (*p++);
27 low = hextoval (*p++);
28 if (high < 0 || low < 0)
29- return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
30+ {
31+ grub_free (buf);
32+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
33+ }
34 expected[i] = (high << 4) | low;
35 }
36 if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
37- return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
38+ {
39+ grub_free (buf);
40+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
41+ }
42 p += 2;
43 if (prefix)
44 {
45@@ -140,7 +146,10 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
46
47 filename = grub_xasprintf ("%s/%s", prefix, p);
48 if (!filename)
49- return grub_errno;
50+ {
51+ grub_free (buf);
52+ return grub_errno;
53+ }
54 file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
55 | (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
56 : GRUB_FILE_TYPE_NONE));
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index 1460e559b9..d18e329b96 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -76,6 +76,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
76 file://0027-libgcrypt-mpi-Fix-possible-NULL-dereference.patch \ 76 file://0027-libgcrypt-mpi-Fix-possible-NULL-dereference.patch \
77 file://0028-syslinux-Fix-memory-leak-while-parsing.patch \ 77 file://0028-syslinux-Fix-memory-leak-while-parsing.patch \
78 file://0029-normal-completion-Fix-leaking-of-memory-when-process.patch \ 78 file://0029-normal-completion-Fix-leaking-of-memory-when-process.patch \
79 file://0030-commands-hashsum-Fix-a-memory-leak.patch \
79 " 80 "
80SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" 81SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
81SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" 82SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"